diff options
-rw-r--r-- | generate_dns_types.go | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/generate_dns_types.go b/generate_dns_types.go index 89ba251..4e2aade 100644 --- a/generate_dns_types.go +++ b/generate_dns_types.go | |||
@@ -1,9 +1,11 @@ | |||
1 | //+build ignore | 1 | //go:build ignore |
2 | 2 | ||
3 | package main | 3 | package main |
4 | 4 | ||
5 | import ( | 5 | import ( |
6 | "bytes" | ||
6 | "fmt" | 7 | "fmt" |
8 | "go/format" | ||
7 | "go/types" | 9 | "go/types" |
8 | "log" | 10 | "log" |
9 | "os" | 11 | "os" |
@@ -182,10 +184,18 @@ func main() { | |||
182 | localTypes[name] = fields | 184 | localTypes[name] = fields |
183 | } | 185 | } |
184 | 186 | ||
187 | // gofmt it! | ||
188 | buf := bytes.Buffer{} | ||
189 | tpl.Execute(&buf, localTypes) | ||
190 | src, err := format.Source(buf.Bytes()) | ||
191 | if err != nil { | ||
192 | panic(err) | ||
193 | } | ||
194 | |||
185 | fp, err := os.Create("zzz_types.go") | 195 | fp, err := os.Create("zzz_types.go") |
186 | if err != nil { | 196 | if err != nil { |
187 | panic(err) | 197 | panic(err) |
188 | } | 198 | } |
189 | defer fp.Close() | 199 | defer fp.Close() |
190 | tpl.Execute(fp, localTypes) | 200 | fp.Write(src) |
191 | } | 201 | } |