Reputation: 171
The documentation is all for Mac OS X and Linux, and I wish to know how to compile a Go package on the Windows platform. On Windows, I do not know how to write the make file and which tool to use to make it.
It seems that there is not a tool named make or go make to use with the installation file of Go development tools.
Upvotes: 16
Views: 66153
Reputation: 991
from: Golang windows, a complete setup guide, http://noypi-linux.blogspot.com/2014/07/golang-windows-complete-setup-guide.html
1) download ZIP
Get the latest code from: http://golang.org/dl/
2) extract ZIP
Extract zip to example C:\local\dev\go
3) create a gopath directory,
Gopath is where third parties will be stored. Example if you will execute a "go get github.com/somelib", this library will be stored in gopath. Create a c:\local\dev\gopath
4) set the environmental variables
open System Properties->Advanced->Environmental Variables
GOROOT=C:\local\dev\go
GOBIN=%GOROOT%\bin
GOPATH=c:\local\dev\gopath
5) add your gobin to PATH
append C:\local\dev\go\bin to PATH
6) test
6.1) create the path "C:\local\dev\gopath\src\myfirstproject"
6.2) create the main.go file "C:\local\dev\gopath\src\myfirstproject\main.go"
package main
import "fmt"
func main() {
fmt.Println("Hi foobar")
}
6.2) you can now build the project anywhere example,
6.2.1) open cmd.exe
6.2.2) cd c:\temp
6.2.3) go build myfirstproject
6.2.4) run myfirstproject.exe
7) get a few libraries
7.1) you can download some free git, svn, and hg for windows
7.2) once you have them you can now do "go get -u github.com/somelib"
8) get an IDE
download liteide
congrats!
Upvotes: 5
Reputation: 92647
There are no more Makefiles needed in Go, so the make
tool isn't necessary. You also do not need cygwin.
If you do not seem to have a valid go
command in your windows shell, then try following the official docs on installing Go for windows
Zip archive
Extract the zip file to the directory of your choice (we suggest c:\Go).
If you chose a directory other than c:\Go, you must set the GOROOT environment variable to your chosen path.
Add the bin subdirectory of your Go root (for example, c:\Go\bin) to to your PATH environment variable.
MSI installer (experimental)
Open the MSI file and follow the prompts to install the Go tools. By default, the installer puts the Go distribution in c:\Go.
The installer should put the c:\Go\bin directory in your PATH environment variable. You may need to restart any open command prompts for the change to take effect.
Setting environment variables under Windows
Under Windows, you may set environment variables through the "Environment Variables" button on the "Advanced" tab of the "System" control panel. Some versions of Windows provide this control panel through the "Advanced System Settings" option inside the "System" control panel.
The last section is important. Your windows PATH environment variable needs to have C:\Go\bin
, so that you will have go
in your path.
Upvotes: 5
Reputation: 166885
Compiling a Go package on Windows is like compiling a Go package on Linux or Mac OS X. Use the go build
command. There is no make file.
Here are some instructions.
Compile packages and dependencies
Upvotes: 10