Golang
Go Basics and Syntax
Go is statically typed, compiled language so types exist. Basic built in types are boolean, integers, floating point numbers, complex numbers and strings(not including collections and such). Syntax:
func fn_name(parameters) return_type{
// code
}
we
Packages in go
Package are a way to group go files together.
LSP
Not exactly realted but if you are trying to use LSP with go, you need to install the gopls
package. If you editor does set it up for you then great but if not then you can do it manually.
go get golang.org/x/tools/gopls@latest
and add the following to your .bashrc
or .zshrc
file
export GO111MODULE=on
export GOPATH={your go path}
export PATH=$PATH:$GOPATH/bin
Now you should be able to use LSP with go.
import
in go
import
is used to import packages.
Tests in Go
We use testing
module for the tests in go.