Today, I will start to learn how to use the GoLang. I am not good at the programming languarge. With this chance, I I hope that I can read the GoLang with basic grammer.
1. Installation
I will follow this instruction, which is offered by "Golang".
wget https://dl.google.com/go/go1.14.1.linux-amd64.tar.gz |
I need to extract this file in any dictionary what you want. In my case, I will extract on my home directory.
# cd /home/ubuntu # tar -xf go1.14.1.linux-amd64.tar.gz # rm -rf go1.14.1.linux-amd64.tar.gz # ls go |
After extracting, I need to edit my environment file to insert the Go binary path.
# vi /etc/environment PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/ubuntu/go/bin" # source /etc/environment |
Now I am ready to study this GoLang.
# go version go version go1.14.1 linux/amd64 |
2. Test my first Go langurage.
I am writing first go programing as the sample like below.
# cat hello.go package main import "fmt" func main() { fmt.Printf("hello, world\n") } |
There is the 2 ways to run this program. At first, It is "run" command. It can be ran without any compile.
# go run hello.go # ls |
In second, it is "build" command. It compile this file and create the binnary file. In this case, "hello" is the compiled file.
Reference
'Programming Basic > GoLang' 카테고리의 다른 글
How to define variables in Golang programming? (0) | 2020.03.22 |
---|