Back to course

Internal vs External Packages

Go (Golang) for Cloud-Native Microservices

Code Organization

In Go, if you create a folder named internal/, the Go compiler prevents other projects from importing those packages.

  • Use internal/ for code private to your microservice.
  • Use pkg/ for code that could be shared with other services.
  • Root level is for your main.go and go.mod.