github.com/tobiash/gqlgen@v0.5.1/codegen/import.go (about)

     1  package codegen
     2  
     3  import (
     4  	"strconv"
     5  )
     6  
     7  type Import struct {
     8  	Name string
     9  	Path string
    10  
    11  	alias string
    12  }
    13  
    14  type Imports struct {
    15  	imports []*Import
    16  	destDir string
    17  }
    18  
    19  func (i *Import) Write() string {
    20  	return i.Alias() + " " + strconv.Quote(i.Path)
    21  }
    22  
    23  func (i *Import) Alias() string {
    24  	if i.alias == "" {
    25  		panic("alias called before imports are finalized")
    26  	}
    27  
    28  	return i.alias
    29  }