joplin-notes/joplin notion extension/Web Development/Go/Initial.md
2026-11-04 00:33:23 +05:30

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

  1. in go every program is part of package that's why here is ths package main
  2. fmt package is imported
  3. main function
  4. fmt.Println is used to print text
  5. Comments are like in C ie // for single line and /* */ for multi line