snapshot of https://github.com/sqlc-dev/sqlc.git (main, 2026-09-16; blobs > 131072B omitted)
Some checks failed
kotlin / test (push) Has been skipped
python / test (push) Has been skipped
typescript / test (push) Has been skipped
go / build darwin/amd64 (push) Has been cancelled
go / build linux/amd64 (push) Has been cancelled
go / build windows/amd64 (push) Has been cancelled
go / build darwin/arm64 (push) Has been cancelled
go / build linux/arm64 (push) Has been cancelled
go / build windows/arm64 (push) Has been cancelled
go / test (push) Has been cancelled
go / vuln_check (push) Has been cancelled
Some checks failed
kotlin / test (push) Has been skipped
python / test (push) Has been skipped
typescript / test (push) Has been skipped
go / build darwin/amd64 (push) Has been cancelled
go / build linux/amd64 (push) Has been cancelled
go / build windows/amd64 (push) Has been cancelled
go / build darwin/arm64 (push) Has been cancelled
go / build linux/arm64 (push) Has been cancelled
go / build windows/arm64 (push) Has been cancelled
go / test (push) Has been cancelled
go / vuln_check (push) Has been cancelled
This commit is contained in:
39
scripts/test-json-process-plugin/main.go
Normal file
39
scripts/test-json-process-plugin/main.go
Normal file
@@ -0,0 +1,39 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
)
|
||||
|
||||
type Out struct {
|
||||
Files []File `json:"files"`
|
||||
}
|
||||
|
||||
type File struct {
|
||||
Name string `json:"name"`
|
||||
Contents []byte `json:"contents"`
|
||||
}
|
||||
|
||||
func main() {
|
||||
in := make(map[string]any)
|
||||
decoder := json.NewDecoder(os.Stdin)
|
||||
err := decoder.Decode(&in)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "error generating JSON: %s", err)
|
||||
os.Exit(2)
|
||||
}
|
||||
|
||||
buf := bytes.NewBuffer(nil)
|
||||
queries := in["queries"].([]any)
|
||||
for _, q := range queries {
|
||||
text := q.(map[string]any)["text"].(string)
|
||||
buf.WriteString(text)
|
||||
buf.WriteString("\n")
|
||||
}
|
||||
|
||||
e := json.NewEncoder(os.Stdout)
|
||||
e.SetIndent("", " ")
|
||||
e.Encode(&Out{Files: []File{{Name: "hello.txt", Contents: buf.Bytes()}}})
|
||||
}
|
||||
Reference in New Issue
Block a user