Go Packages

Exporting names

// Begin with a capital letter
func Hello () {
  ···
}

See: Exported names

Packages

package main
// An internal package may be imported only by another package
// that is inside the tree rooted at the parent of the internal directory
package internal

See: Internal packages

Aliases

import r "math/rand"

import (
    "fmt"
    r "math/rand"
)

r.Intn()

Importing

import "fmt"
import "math/rand"

#Same as

import (
  "fmt"        // gives fmt.Println
  "math/rand"  // gives rand.Intn
)

See: Importing

Comments