Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump github.com/golang/protobuf from 1.4.3 to 1.5.1 #53

Closed
Prev Previous commit
Next Next commit
update make-snippets.go
  • Loading branch information
kralicky committed Mar 17, 2021
commit 941a6d4da93c000e9dde01d9cb82d6f32854198a
16 changes: 11 additions & 5 deletions hack/make-snippets.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
)

type snippets struct {
Items map[string]snippet `json:",inline"`
Items map[string]*snippet `json:",inline"`
}

type snippet struct {
Expand All @@ -23,6 +23,11 @@ type snippet struct {
Description string `json:"description,omitempty"`
}

var header = `// Code generated by make-snippets.go. DO NOT EDIT.
// Snippets should be edited in hack/snippets.yaml.
// Re-generate this file by running hack/make-snippets.go.
`

func main() {
here, err := os.Getwd()
if err != nil {
Expand Down Expand Up @@ -53,16 +58,17 @@ func main() {
if sn.Description == "" {
sn.Description = name
}
sn.Body = strings.ReplaceAll(sn.Body, "\t", `\t`)
sn.Body = strings.ReplaceAll(sn.Body, "\n", `\n`)
sn.Body = strings.ReplaceAll(sn.Body, " ", ` `)
sn.Body = strings.ReplaceAll(sn.Body, `\\n`, `\n`)
items[name] = sn
}
jsonData, err := json.MarshalIndent(items, "", " ")
if err != nil {
log.Fatal(err)
}
os.MkdirAll("../.vscode", 0o775)
err = os.WriteFile("../.vscode/kubecc.code-snippets", jsonData, 0o644)
os.MkdirAll(filepath.Join(here, ".vscode"), 0o775)
err = os.WriteFile(filepath.Join(here, ".vscode/kubecc.code-snippets"),
append([]byte(header), jsonData...), 0o644)
if err != nil {
log.Fatal(err)
}
Expand Down