-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Sean@TPE edited this page Nov 17, 2017
·
1 revision
Welcome to the HelloGo wiki!
A workspace is a directory hierarchy with three directories at its root:
- src contains Go source files,
- pkg contains package objects, and
- bin contains executable commands.
Note: The following command is just for Windows
Printing the effective current go environment variables:
>go env
Before build your go code, you have to set the GOPATH:
>set GOPATH=[path of your workspace]
You can use the following command or go env
, go env GOPATH
to make sure that the environment variable be set:
>echo %GOPATH%
Suppose your directory hierarchy is
Workspace
├ bin
├ pkg
└ src
└ hello
└ hello.go
1.set GOPATH
>set GOPATH=[the absolute path of Workspace]
2.compile
>go install hello
(the command is go install [package_name]
)
You can also omit the package path if you run go install from the package directory
>cd src\hello
>go install
3.This command install the binary to Workspace's bin directory as hello.exe.