summaryrefslogtreecommitdiff
path: root/header.go
blob: 1947705c545533a7c91018b3dadad4ddf623bfae (plain)
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package main

import (
	"fmt"
	"io"
)

func pbHeaderComment(w io.Writer) {
	// technically this should be the first line and in this exact format:
	fmt.Fprintln(w, "// Code modified by go.wit.com/apps/autogenpb. DO NOT EDIT.")
	fmt.Fprintln(w, "//")
	fmt.Fprintln(w, "// user defined Mutex locks were auto added")
	fmt.Fprintln(w, "//")
	fmt.Fprintln(w, "// autogenpb version & build time:", VERSION, BUILDTIME)
	fmt.Fprintln(w, "// autogenpb auto generates Sort(), Unique() and Marshal() functions")
	fmt.Fprintln(w, "//     go install go.wit.com/apps/autogenpb@latest")
	fmt.Fprintln(w, "")
}

func headerComment(w io.Writer) {
	// technically this should be the first line and in this exact format:
	fmt.Fprintln(w, "// Code generated by go.wit.com/apps/autogenpb. DO NOT EDIT.")
	fmt.Fprintln(w, "// This file was autogenerated with autogenpb", VERSION, BUILDTIME)
	fmt.Fprintln(w, "//     go install go.wit.com/apps/autogenpb@latest")
	fmt.Fprintln(w, "//")
	fmt.Fprintln(w, "// You can use it on simple protobuf files")
	fmt.Fprintln(w, "// The .proto file must have a singular and plural form of a message")
	fmt.Fprintln(w, "// (for those of you that know ruby on rails, it's like that)")
	fmt.Fprintln(w, "//")
	fmt.Fprintln(w, "// You can mark which repos you want to auto generate sort.pb.go and marshal.pb.go files for")
	fmt.Fprintln(w, "//")
	fmt.Fprintln(w, "// For an example,")
	fmt.Fprintln(w, "//       go-clone go.wit.com/lib/protobuf/gitpb")
	fmt.Fprintln(w, "//")
	fmt.Fprintln(w, "")
}

func header(w io.Writer, pf *File) {
	// header must come first
	headerComment(w)
	fmt.Fprintf(w, "package %s\n", pf.Package)
	fmt.Fprintln(w, "")
	fmt.Fprintln(w, "import (")
	fmt.Fprintln(w, "	\"fmt\"")
	fmt.Fprintln(w, "	\"sort\"")
	fmt.Fprintln(w, "	\"sync\"")
	fmt.Fprintln(w, ")")
	fmt.Fprintln(w, "")
}