libgo: update to Go 1.11
[official-gcc.git] / libgo / go / cmd / go / internal / modconv / vjson.go
blobeec86b733985d1263927026c32fbdf0514d9cc13
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.
5 package modconv
7 import (
8 "encoding/json"
10 "cmd/go/internal/modfile"
11 "cmd/go/internal/module"
14 func ParseVendorJSON(file string, data []byte) (*modfile.File, error) {
15 var cfg struct {
16 Package []struct {
17 Path string
18 Revision string
21 if err := json.Unmarshal(data, &cfg); err != nil {
22 return nil, err
24 mf := new(modfile.File)
25 for _, d := range cfg.Package {
26 mf.Require = append(mf.Require, &modfile.Require{Mod: module.Version{Path: d.Path, Version: d.Revision}})
28 return mf, nil