Tech/Languages/GoLang

From lathama
Jump to navigation Jump to search

GoLang or Go is a popular language and it is widely used.

Example

Hello World is the standard example so lets do one.

We have to setup an env first

go mod init example/helloworld
go: creating new go.mod: module example/helloworld

Then a helloworld.go

package main

import "fmt"

func main() {
    fmt.Println("Hello World")
}

Then we run

go run .
Hello World

For packages you would compile but that is another topic.

Risks

In my career I have already discovered and addressed major security issues in GoLang software. GoLang is an awesome language but it is no match for lazy copy-paste developers. GoLang can import or include from HTTP URLs and cache on the development machine. So a developer can build something working on their machine and when a move to QA/Production happens it could be found that the includes no longer exist. I have witnessed and fixed this exact thing. This is not the fault of the language, just an unplanned "feature".

Please read https://www.theregister.com/2016/03/23/npm_left_pad_chaos/

Resources