860 B
860 B
Initial
Install go compiler.
Sample program
// file name : main.go
package main
import ("fmt")
func main() {
fmt.Println("Hello World!")
}
then run go run main.go or go build -o main main.go && ./main.
for partilcular platform
GOOS=linux GOARCH=arm64 go build -o myapp-linux-arm64 .
and equivalent of npm i
to install all packages
go get . or go mod tidy
to install specific package
go get github.com/spf13/cobra@latest
to remove go package
simply remove import statements and then run go mod tidy
for initiating like npm init -y
use go mod init <module_name>
Program explanation
- in go every program is part of package that's why here is ths package main
- fmt package is imported
- main function
- fmt.Println is used to print text
- Comments are like in C ie
//for single line and/* */for multi line