=======
- Get the current archive from the list at - https://golang.org/dl/
- Untar it . For example
- tar xvf go1.3.3.src.tar.gz
- A new directory of "go" will be generated.
- cd to go/src
- run all.bash
- ./all.bash
- Now the go binary will be generated at the go/bin directory.( check whether go and gofmt binaries are generated or not)
- Open the file ~/.bashrc
- Add the PATH variable with the bin directory to your .bashrc file at the end like
- #PATH=$PATH:/home/arun/Documents/GITHUB/golan/go/bin
- Save the file.
- Now we can run a go file directly.
- Write a hello.go using any editor. For example
- vim hello.go
- press i for insert
- copy the code below from here.
package main
import "fmt"
func main(){
fmt.Printf("Hi How r u\n")
}
import "fmt"
func main(){
fmt.Printf("Hi How r u\n")
}
- press the ctrl+shift+v to copy the file to termival vim.
- press esc and :wq to write and quit.
- to run the code try
- go run hello.go
- If everything went right you will see the "Hi How r u" statement on terminal.
- Thats it!
No comments:
Post a Comment