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:
- import (
- pb "github.com/golang/groupcache/groupcachepb"
- )
You can also import packages that you won't actually use. E.g.
- import (
- _ "image/png" // import can do magic
- )
Python
- import string as s
- print s.upper("world")
Go
- package main
- import (
- "fmt"
- s "strings"
- )
- func main() {
- fmt.Println(s.ToUpper("world"))
- }