Skip to content

GeekEast/complete-golang

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Table Of Content

Start Go on MacOS

  • Install brew install go
  • IDE
    • VScode: lightweight choice
      • go: you will install other dependencies
      • go snippets
    • GoLand: standard choice
  • Run go run hello.go

Hello Golang

// main.go
package main // required

import "fmt" // required

const text = "Hello Golang" // package-level var

func getText() string {
  text := "hello Golang" // local to getText()
  return text
}

func main() {  // required
  fmt.Println(text)
  fmt.Println(getText())
}

Go CMD

go env         // environment variables
go build       // build to binary
go get         // install packages
go version     // version of go
  • GOROOT: includes cmd, standard lib and go compiler
  • GOPATH: after 1.11, you don't have to worry about this 👇

Go Module

  • Before 1.11, you will always to change GOPATH to your current project folder.
  • Now, you can use go mod to map dependencies in GOPATH and don't need to change GOPATH anymore
export GO111MODULE=off   # turn off module system
go mod init essential-go # init module
go list -m all           # list dependencies
go mod tidy              # remove unused 
go get -u                # update all

Future Plan

Learning Resources

About

Complete introduction to golang

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages