// Copyright 2018 The Go Authors. All rights reserved.// Use of this source code is governed by a BSD-style// license that can be found in the LICENSE file.
// Package packagesdriver fetches type sizes for go/packages and go/analysis.
package packagesdriverimport ()// TODO(adonovan): move back into go/packages.func ( context.Context, gocommand.Invocation, *gocommand.Runner) (string, string, error) { .Verb = "list" .Args = []string{"-f", "{{context.GOARCH}} {{context.Compiler}}", "--", "unsafe"} , , , := .RunRaw(, )var , stringif != nil { := .Error()ifstrings.Contains(, "cannot find main module") ||strings.Contains(, "go.mod file not found") {// User's running outside of a module. // All bets are off. Get GOARCH and guess compiler is gc. // TODO(matloob): Is this a problem in practice? .Verb = "env" .Args = []string{"GOARCH"} , := .Run(, )if != nil {return"", "", } = strings.TrimSpace(.String()) = "gc" } elseif != nil {return"", "", } else {// This should be unreachable, but be defensive // in case RunRaw's error results are inconsistent.return"", "", } } else { := strings.Fields(.String())iflen() < 2 {return"", "", fmt.Errorf("could not parse GOARCH and Go compiler in format \"<GOARCH> <compiler>\":\nstdout: <<%s>>\nstderr: <<%s>>", .String(), .String()) } = [0] = [1] }return , , nil}
The pages are generated with Goldsv0.7.6. (GOOS=linux GOARCH=amd64)