Import Alias

This example is a bit silly because you normally don't bother with analias for short built-ins. It's import appropriate for long importnameslike:

  1. import (
  2. pb "github.com/golang/groupcache/groupcachepb"
  3. )

You can also import packages that you won't actually use. E.g.

  1. import (
  2. _ "image/png" // import can do magic
  3. )

Python

  1. import string as s
  2.  
  3. print s.upper("world")

Go

  1. package main
  2.  
  3. import (
  4. "fmt"
  5. s "strings"
  6. )
  7.  
  8. func main() {
  9. fmt.Println(s.ToUpper("world"))
  10. }