autogenpb/generateHeader.go

46 lines
1.6 KiB
Go
Raw Normal View History

2024-12-16 00:18:30 -06:00
package main
import (
"fmt"
"io"
)
2025-01-09 06:05:38 -06:00
func pbHeaderComment(w io.Writer) {
// technically this should be the first line and in this exact format:
2025-01-09 06:47:35 -06:00
fmt.Fprintln(w, "// Code modified by go.wit.com/apps/autogenpb DO NOT EDIT.")
2025-01-09 06:05:38 -06:00
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, "")
}
2024-12-16 00:18:30 -06:00
func headerComment(w io.Writer) {
// technically this should be the first line and in this exact format:
2025-01-09 06:47:35 -06:00
fmt.Fprintln(w, "// Code generated by go.wit.com/apps/autogenpb DO NOT EDIT.")
2025-01-09 06:05:38 -06:00
fmt.Fprintln(w, "// This file was autogenerated with autogenpb", VERSION, BUILDTIME)
2024-12-16 00:18:30 -06:00
fmt.Fprintln(w, "// go install go.wit.com/apps/autogenpb@latest")
fmt.Fprintln(w, "//")
2025-01-09 06:47:35 -06:00
fmt.Fprintln(w, "// define which structs (messages) you want to use in the .proto file")
fmt.Fprintln(w, "// Then sort.pb.go and marshal.pb.go files are autogenerated")
2024-12-16 00:18:30 -06:00
fmt.Fprintln(w, "//")
2025-01-09 06:47:35 -06:00
fmt.Fprintln(w, "// autogenpb uses it and has an example .proto file with instructions")
2024-12-16 00:18:30 -06:00
fmt.Fprintln(w, "//")
fmt.Fprintln(w, "")
}
func header(w io.Writer, pf *File) {
// header must come first
2024-12-16 00:18:30 -06:00
headerComment(w)
fmt.Fprintf(w, "package %s\n", pf.Package)
fmt.Fprintln(w, "")
2024-12-16 00:18:30 -06:00
fmt.Fprintln(w, "import (")
2025-01-11 06:07:48 -06:00
// fmt.Fprintln(w, " \"fmt\"")
2024-12-16 00:18:30 -06:00
fmt.Fprintln(w, " \"sort\"")
fmt.Fprintln(w, " \"sync\"")
fmt.Fprintln(w, ")")
fmt.Fprintln(w, "")
}