Black Lives Matter. Support the Equal Justice Initiative.

Source file src/cmd/go/internal/modconv/vmanifest.go

Documentation: cmd/go/internal/modconv

     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  	"encoding/json"
     9  
    10  	"golang.org/x/mod/modfile"
    11  	"golang.org/x/mod/module"
    12  )
    13  
    14  func ParseVendorManifest(file string, data []byte) (*modfile.File, error) {
    15  	var cfg struct {
    16  		Dependencies []struct {
    17  			ImportPath string
    18  			Revision   string
    19  		}
    20  	}
    21  	if err := json.Unmarshal(data, &cfg); err != nil {
    22  		return nil, err
    23  	}
    24  	mf := new(modfile.File)
    25  	for _, d := range cfg.Dependencies {
    26  		mf.Require = append(mf.Require, &modfile.Require{Mod: module.Version{Path: d.ImportPath, Version: d.Revision}})
    27  	}
    28  	return mf, nil
    29  }
    30  

View as plain text