Import Aliasing

Import aliasing must be used if the package name does not match the lastelement of the import path.

  1. import (
  2. "net/http"
  3.  
  4. client "example.com/client-go"
  5. trace "example.com/trace/v2"
  6. )

In all other scenarios, import aliases should be avoided unless there is adirect conflict between imports.

BadGood
  1. import (
  2. "fmt"
  3. "os"
  4.  
  5.  
  6. nettrace "golang.net/x/trace"
  7. )
  1. import (
  2. "fmt"
  3. "os"
  4. "runtime/trace"
  5.  
  6. nettrace "golang.net/x/trace"
  7. )