Go: `go run` and `go build` does not compile/run

Created on 28 Aug 2017  路  2Comments  路  Source: golang/go

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

go1.9 darwin/amd64

Does this issue reproduce with the latest release?

Yes.

What operating system and processor architecture are you using (go env)?

macOS Sierra 10.12.6 - amd64

What did you do?

If possible, provide a recipe for reproducing the error.
A complete runnable program is good.
A link on play.golang.org is best.

cd sample
go run sample.go
Also tried
go run build.go
The link for play.golang.org

What did you expect to see?

I expected to see "Hello World" printed out but rather received the following below:

What did you see instead?

```

command-line-arguments

flag provided but not defined: -goversion
usage: compile [options] file.go...
-% debug non-static initializers
-+ compiling runtime
-B disable bounds checking
-D path
set relative path for local imports
-E debug symbol export
-I directory
add directory to import search path
-K debug missing line numbers
-N disable optimizations
-S print assembly listing
-V print compiler version
-W debug parse tree after type checking
-asmhdr file
write assembly header to file
-bench file
append benchmark times to file
-buildid id
record id as the build id in the export metadata
-complete
compiling complete package (no C or assembly)
-cpuprofile file
write cpu profile to file
-d list
print debug information about items in list
-dynlink
support references to Go symbols defined in other shared libraries
-e no limit on number of errors reported
-f debug stack frames
-h halt on error
-i debug line number stack
-importmap definition
add definition of the form source=actual to import map
-installsuffix suffix
set pkg directory suffix
-j debug runtime-initialized variables
-l disable inlining
-largemodel
generate code that assumes a large memory model
-linkobj file
write linker-specific object to file
-live
debug liveness analysis
-m print optimization decisions
-memprofile file
write memory profile to file
-memprofilerate rate
set runtime.MemProfileRate to rate
-msan
build code compatible with C/C++ memory sanitizer
-nolocalimports
reject local (relative) imports
-o file
write output to file
-p path
set expected package import path
-pack
write package file instead of object file
-r debug generated wrappers
-race
enable race detector
-s warn about composite literals that can be simplified
-shared
generate code that can be linked into a shared library
-traceprofile file
write an execution trace to file
-trimpath prefix
remove prefix from recorded source file paths
-u reject unsafe code
-v increase debug verbosity
-w debug type checking
-wb
enable write barrier (default true)

FrozenDueToAge

Most helpful comment

Apparently, I manually had $GOROOT defined in my bash_profile, I removed it, and it's working fine now. I'll go ahead and close the issue.

All 2 comments

Apparently, I manually had $GOROOT defined in my bash_profile, I removed it, and it's working fine now. I'll go ahead and close the issue.

http://prntscr.com/j0rfh6
i am using go 10.1 how i build my first doc i-e 'hello.go'

Was this page helpful?
0 / 5 - 0 ratings