...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package main
18
19 import (
20 "encoding/base64"
21 "io/ioutil"
22 "os"
23 )
24
25 func check(err error) {
26 if err != nil {
27 panic(err)
28 }
29 }
30
31 func write(f *os.File, s string) {
32 _, err := f.WriteString(s)
33 check(err)
34 }
35
36 func main() {
37 f, err := os.Create("base.go")
38 check(err)
39
40 defer f.Close()
41
42 write(f, `
43 // THIS FILE IS AUTOMATICALLY GENERATED.
44
45 package jsonschema
46
47 import (
48 "encoding/base64"
49 )
50
51 func baseSchemaBytes() ([]byte, error){
52 return base64.StdEncoding.DecodeString(
53 `)
54 write(f, "`")
55
56 b, err := ioutil.ReadFile("schema.json")
57 check(err)
58
59 s := base64.StdEncoding.EncodeToString(b)
60 limit := len(s)
61 width := 80
62 for i := 0; i < limit; i += width {
63 if i > 0 {
64 write(f, "\n")
65 }
66 j := i + width
67 if j > limit {
68 j = limit
69 }
70 write(f, s[i:j])
71 }
72 write(f, "`)}")
73 }
74
View as plain text