This page is all about Go language
Some features of Go lang
- First released in open source to the community in 2009 by Google'
- Looks and feels like C language
- Statically typed
- Compiled
Go toolchain (refers to the set of commands, tools and utilities that are used to build, test, and manage Go (Golang) programs. The Go toolchain includes various commands and tools that work together to help developers write, compile, test, and deploy Go applications) has a number of static analysis tools and below are to name a few
- gofmt
- golint
- go vet
Some resources related to Go
- Info about Go is available here
- Where to practice or get hands on? Go Playground
- Documentation link
Installing "Go" on Ubuntu
This is like 3 step process
- Download binary
- Navigate to the location of the Binary: sudo tar -C /usr/local/ -xvzf go1.23.3.linux-amd64.tar.gz
- Set the PATH as shown below.
osuser@osuser-VMware-Virtual-Platform:~/Downloads$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin
osuser@osuser-VMware-Virtual-Platform:~/Downloads$ export PATH=$PATH:/usr/local/go/bin
osuser@osuser-VMware-Virtual-Platform:~/Downloads$
osuser@osuser-VMware-Virtual-Platform:~/Downloads$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin:/usr/local/go/bin
osuser@osuser-VMware-Virtual-Platform:~/Downloads$
Sample Go program:
############# Begins here
// You can edit this code!
// Click here and start typing.
package main
import "fmt"
func main() {
fmt.Println("Hello, World")
}
############# Ends here
Every source code must
- begin with package; package is used to Organize and Group code
- have at least one main function declared with zero arguments and return values which is the entry point for the compiler at the runtime
Running a Go program:
- go run .\main.go
No comments:
Post a Comment