Getting Start

Links:

Steps:

Write some code

  1. Create a directory:

    mkcd hello

  2. Initialize:
    go mod init example/hello

  3. Createa file: hello.go
    code hello.go

  4. Add code:

    package main
    import "fmt"
    
    func main() {
        fmt.Println("Hello, World!")
    }
  5. Run Code:
    go run .

Call code in an external package

  1. Install Module (like Pip in Python):

    go get rsc.io/quote

  2. After importing module add this to code:

    package main
    import "fmt"
    import "rsc.io/quote"
    
    func main() {
        fmt.Println(quote.Go())
    }
  3. Add new module requirements and sums. go mod tody

  4. Run go run .

  5. Build go build .

  6. Execute ./hello