Creating and Using Packages

Packages in Go help organize code into reusable modules.

  • Each Go file declares a package name with package.
  • Use import to bring in packages.
  • Exported identifiers start with a capital letter.
package mymath

func Add(a int, b int) int {
    return a + b
}
← PrevNext →