2024-11-29 08:30:19 -06:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"io"
|
|
|
|
"os"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
f, _ := os.OpenFile("test.sort.pb.go", os.O_WRONLY|os.O_CREATE, 0600)
|
2024-11-29 08:33:47 -06:00
|
|
|
header(f, "autogenpb")
|
|
|
|
syncLock(f, "godeplock")
|
2024-11-29 08:30:19 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
func header(w io.Writer, name string) {
|
2024-11-29 08:33:47 -06:00
|
|
|
fmt.Fprintln(w, "package " + name)
|
2024-11-29 08:30:19 -06:00
|
|
|
fmt.Fprintln(w, "")
|
|
|
|
fmt.Fprintln(w, "// this is becoming a standard format")
|
|
|
|
fmt.Fprintln(w, "// todo: autogenerate this from the .proto file?")
|
|
|
|
fmt.Fprintln(w, "")
|
|
|
|
fmt.Fprintln(w, "import (")
|
|
|
|
fmt.Fprintln(w, " \"fmt\"")
|
|
|
|
fmt.Fprintln(w, " \"os\"")
|
|
|
|
fmt.Fprintln(w, " \"sort\"")
|
|
|
|
fmt.Fprintln(w, " \"sync\"")
|
|
|
|
fmt.Fprintln(w, ")")
|
|
|
|
fmt.Fprintln(w, "")
|
2024-11-29 08:33:47 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
func syncLock(w io.Writer, name string) {
|
2024-11-29 08:30:19 -06:00
|
|
|
fmt.Fprintln(w, "// bad global lock until I figure out some other plan")
|
2024-11-29 08:33:47 -06:00
|
|
|
fmt.Fprintln(w, "var " + name + " sync.RWMutex")
|
2024-11-29 08:30:19 -06:00
|
|
|
fmt.Fprintln(w, "")
|
|
|
|
}
|