Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 44ceda1

Browse files
committed
Remove comment line handling in example parsing
JSON does not support comments, so remove the code that handled discarding a comment line in the example parsing. This prevents errors when reading the JSON examples.
1 parent 3b396d3 commit 44ceda1

File tree

2 files changed

+0
-12
lines changed

2 files changed

+0
-12
lines changed

examples/examples.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,6 @@ func parseAndVerifyExamples() (examples []codersdk.TemplateExample, err error) {
6868
defer f.Close()
6969

7070
b := bufio.NewReader(f)
71-
72-
// Discard the first line (code generated by-comment).
73-
_, _, err = b.ReadLine()
74-
if err != nil {
75-
return nil, xerrors.Errorf("read %s: %w", examplesJSON, err)
76-
}
77-
7871
err = json.NewDecoder(b).Decode(&examples)
7972
if err != nil {
8073
return nil, xerrors.Errorf("decode %s: %w", examplesJSON, err)

scripts/examplegen/main.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,6 @@ func run(lint bool) error {
9292
w = io.Discard
9393
}
9494

95-
_, err = fmt.Fprint(w, "// Code generated by examplegen. DO NOT EDIT.\n")
96-
if err != nil {
97-
return err
98-
}
99-
10095
enc := json.NewEncoder(w)
10196
enc.SetIndent("", "\t")
10297
return enc.Encode(examples)

0 commit comments

Comments
 (0)