setup generation
This commit is contained in:
parent
06845ed750
commit
5acfd28ccc
12
internal/dictionary/words.go
Normal file
12
internal/dictionary/words.go
Normal file
@ -0,0 +1,12 @@
|
||||
// Code generated by go generate; DO NOT EDIT.
|
||||
// This file was generated by robots at
|
||||
// 2025-06-30 15:25:49.978118211 +0200 CEST m=+0.000535670
|
||||
// using data from
|
||||
// /usr/shared/dictionary/words
|
||||
package dictionary
|
||||
|
||||
var Words = []string{
|
||||
"foo",
|
||||
"bar",
|
||||
"baz",
|
||||
}
|
56
internal/gen.go
Normal file
56
internal/gen.go
Normal file
@ -0,0 +1,56 @@
|
||||
//go:build ignore
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"text/template"
|
||||
"time"
|
||||
)
|
||||
|
||||
const Path = "/usr/shared/dictionary/words"
|
||||
|
||||
func main() {
|
||||
fmt.Println("Generate")
|
||||
|
||||
f, err := os.Create("internal/dictionary/words.go")
|
||||
die(err)
|
||||
defer f.Close()
|
||||
|
||||
packageTemplate.Execute(f, struct {
|
||||
Timestamp time.Time
|
||||
Path string
|
||||
Words []string
|
||||
}{
|
||||
Timestamp: time.Now(),
|
||||
Path: Path,
|
||||
Words: []string{
|
||||
"foo",
|
||||
"bar",
|
||||
"baz",
|
||||
},
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
func die(err error) {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
var packageTemplate = template.Must(template.New("").Parse(`// Code generated by go generate; DO NOT EDIT.
|
||||
// This file was generated by robots at
|
||||
// {{ .Timestamp }}
|
||||
// using data from
|
||||
// {{ .Path }}
|
||||
package dictionary
|
||||
|
||||
var Words = []string{
|
||||
{{- range .Words }}
|
||||
{{ printf "%q" . }},
|
||||
{{- end }}
|
||||
}
|
||||
`))
|
Loading…
x
Reference in New Issue
Block a user