github.com/yukk001/go1.10.8@v0.0.0-20190813125351-6df2d3982e20/src/cmd/go/internal/version/version.go (about) 1 // Copyright 2011 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 version implements the ``go version'' command. 6 package version 7 8 import ( 9 "fmt" 10 "runtime" 11 12 "cmd/go/internal/base" 13 ) 14 15 var CmdVersion = &base.Command{ 16 Run: runVersion, 17 UsageLine: "version", 18 Short: "print Go version", 19 Long: `Version prints the Go version, as reported by runtime.Version.`, 20 } 21 22 func runVersion(cmd *base.Command, args []string) { 23 if len(args) != 0 { 24 cmd.Usage() 25 } 26 27 fmt.Printf("go version %s %s/%s\n", runtime.Version(), runtime.GOOS, runtime.GOARCH) 28 }