github.com/zxy12/go_duplicate_112_new@v0.0.0-20200807091221-747231827200/src/cmd/go/internal/modconv/vconf.go (about)

     1  // Copyright 2018 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package modconv
     6  
     7  import (
     8  	"strings"
     9  
    10  	"cmd/go/internal/modfile"
    11  	"cmd/go/internal/module"
    12  )
    13  
    14  func ParseVendorConf(file string, data []byte) (*modfile.File, error) {
    15  	mf := new(modfile.File)
    16  	for lineno, line := range strings.Split(string(data), "\n") {
    17  		lineno++
    18  		if i := strings.Index(line, "#"); i >= 0 {
    19  			line = line[:i]
    20  		}
    21  		f := strings.Fields(line)
    22  		if len(f) >= 2 {
    23  			mf.Require = append(mf.Require, &modfile.Require{Mod: module.Version{Path: f[0], Version: f[1]}})
    24  		}
    25  	}
    26  	return mf, nil
    27  }