diff options
| author | Jeff Carr <[email protected]> | 2025-01-08 19:45:48 -0600 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-01-08 19:45:48 -0600 |
| commit | 3fe2fde185b950215008e67a50364ec741f2fd09 (patch) | |
| tree | 25392d9c486a324afe61239d54b5e4395d3a3000 /addMutex.go | |
| parent | 0a1eb821e9123f4e6793b410300803c610d4b804 (diff) | |
make a protofile for the app itself
that turns out to be a lot of fun!
Diffstat (limited to 'addMutex.go')
| -rw-r--r-- | addMutex.go | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/addMutex.go b/addMutex.go index 082d1bc..fc1af97 100644 --- a/addMutex.go +++ b/addMutex.go @@ -13,8 +13,8 @@ import ( "go.wit.com/log" ) -func addMutex(names map[string]string) error { - fullname := names["protobase"] + ".pb.go" +func (pb *Files) addMutex(f *File) error { + fullname := f.Filebase + ".pb.go" log.Info("fullname:", fullname) data, err := os.ReadFile(fullname) if err != nil { @@ -22,14 +22,21 @@ func addMutex(names map[string]string) error { return err } - w, _ := os.OpenFile(names["protobase"]+".pb.go", os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644) + w, _ := os.OpenFile(f.Filebase+".pb.go", os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644) var found bool lines := strings.Split(string(data), "\n") for _, line := range lines { + if strings.HasPrefix(line, "package ") { + log.Info("CHANGING package:", line, "to package:", f.Package) + fmt.Fprintln(w, "package "+f.Package) + // log.Info("CHANGING package:", line, "to package:main") + // fmt.Fprintln(w, "package "+"main") + continue + } // log.Info("line:", line) - start := "type " + names["Bases"] + " struct {" + start := "type " + "sunshine" + " struct {" if strings.HasSuffix(line, start) { found = true log.Info("FOUND line:", line) |
