-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerator_header.go
32 lines (29 loc) · 941 Bytes
/
generator_header.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// Copyright 2014 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package main
func (g *Generator) buildHeader(cliArgs string) {
g.Printf("// Code generated by \"go-stringer %s\"; DO NOT EDIT.\n", cliArgs)
g.Printf("\n")
g.Printf("package %s", g.pkg.name)
g.Printf("\n")
// imports
if !g.fromStringGenFn && (g.marshallingParams == nil || !g.marshallingParams.IsInit()) {
g.Printf("import \"strconv\"\n") // Used by all methods.
} else {
g.Printf("import (\n")
g.Printf("\t\"strconv\"\n") // Used by all methods.
if g.fromStringGenFn {
g.Printf("\t\"errors\"\n")
}
if g.marshallingParams != nil {
if g.marshallingParams.QS {
g.Printf("\tqs \"%s\"\n", g.marshallingParams.PackageQS)
}
if g.marshallingParams.JSON {
g.Printf("\tjson \"%s\"\n", g.marshallingParams.PackageJSON)
}
}
g.Printf(")\n")
}
}