- Go to the download page on golang website: https://golang.org/dl/
- Choose the package file according to your operating system
- Download the package file, extract it, and follow the prompts to install the Go tools.
- For Windows open the MSI file and follow the prompts to install the Go tools. By default, the installer puts the Go distribution in the c:/Go
- Ths installer should direct the Go path to the c:\Go\bin in your PATH environment variable. To check that open terminal and type
go env - If the GoPATH was directed to somewhere else, you can edit it through the "Environment Variables" button on the "Advaced System Settings" option inside the "System" control panel.
sudo apt-get updatesudo apt-get upgradecurl -O https://dl.google.com/go/go1.10.3.linux-amd64.tar.gztar -xzvf go1.10.3.linux-amd64.tar.gzsudo mv go /usr/local
sudo pacman -S go go-tools
curl -O https://dl.google.com/go/go1.10.3.darwin-amd64.pkg- Execute
sudo installer -pkg /your/path/go1.10.3.darwin-amd64.pkg -target /then next/next/finish (you can find the path using the pwd command) - OR
brew install go
- On terminal you need to set up a workspace that consist of the three forlders (bin/ src/ pkg/) at the root (in this case the root is c:\projects\Go) using the following commands:
mkdir c:\projects\Gomkdir c:\projects\Go\binmkdir c:\projects\Go\pkgmkdir c:\projects\Go\src
Then set up the GOPATH
- `set GOPATH=c:\projects\Go\bin`
- `set PATH=%PATH%`
-
Linux and Mac: paste the following commands in terminal:
mkdir ~/gonano ~/.bashrcexport GOPATH=$HOME/goexport PATH=$PATH:$GOPATH/bin- OR
export PATH=$PATH:/usr/local/go/bin:$GOPATH/bin- for Debian/Ubuntu
go env
NOTE: as example is used Dispatch disgo node
go get github.com/dispatchlabs/disgocd $GOPATH/src/github.com/dispatchlabs/disgogo run main.go
go get github.com/dispatchlabs/disgocd $GOPATH/src/github.com/dispatchlabs/disgogo buildsudo mkdir /go-binariessudo mv $GOPATH/bin/disgo /go-binaries/sudo cp -r ./properties /go-binaries/sudo nano /etc/systemd/system/dispatch-disgo-node.service
[Unit]
Description=Dispatch Disgo Node
After=network.target
[Service]
WorkingDirectory=/go-binaries
ExecStart=/go-binaries/disgo -asSeed -nodeId=NODE-Seed-001
Restart=on-failure
User=dispatch-services
Group=dispatch-services
[Install]
WantedBy=multi-user.targetsudo useradd dispatch-services -s /sbin/nologin -Msudo systemctl enable dispatch-disgo-nodesudo systemctl start dispatch-disgo-nodesudo journalctl -f -u dispatch-disgo-nodesudo systemctl daemon-reloadif you change the service