all functions are passed the informationn in the protobuf

This commit is contained in:
Jeff Carr 2025-01-09 05:20:00 -06:00
parent e6a3329628
commit 78bfce745b
4 changed files with 12 additions and 9 deletions

View File

@ -23,10 +23,11 @@ func headerComment(w io.Writer) {
fmt.Fprintln(w, "")
}
func header(w io.Writer, names map[string]string) {
func header(w io.Writer, pf *File) {
// header must come first
headerComment(w)
fmt.Fprintln(w, "package "+names["package"])
fmt.Fprintf(w, "package %s\n", pf.Package)
fmt.Fprintln(w, "")
fmt.Fprintln(w, "import (")
fmt.Fprintln(w, " \"fmt\"")
fmt.Fprintln(w, " \"sort\"")

View File

@ -166,7 +166,8 @@ func main() {
sortmap["Bases"] = sortmap["Base"] + "s"
}
// pb.makeSortfile(f)
pb.makeSortfile(f)
pb.makeNewSortfile(f)
}
func okExit(s string) {

View File

@ -7,10 +7,11 @@ import (
"strings"
)
func makeSortfile() {
f, _ := os.OpenFile(sortmap["protobase"]+".sort.pb.go", os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644)
// passes in the protobuf file protobuf
func (pb *Files) makeSortfile(pf *File) {
f, _ := os.OpenFile(pf.Filebase+".sort.pb.go", os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644)
header(f, sortmap)
header(f, pf)
if sortmap["lock"] == "all" {
// if the lock is set to 'all' this means the mutex was put in the protoc-gen-go struct

View File

@ -5,10 +5,10 @@ import (
"strings"
)
func makeNewSortfile() {
f, _ := os.OpenFile(sortmap["protobase"]+".newsort.pb.go", os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644)
func (pb *Files) makeNewSortfile(pf *File) {
f, _ := os.OpenFile(pf.Filebase+".newsort.pb.go", os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644)
header(f, sortmap)
header(f, pf)
if sortmap["lock"] == "all" {
// if the lock is set to 'all' this means the mutex was put in the protoc-gen-go struct