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
40 lines
727 B
Go
40 lines
727 B
Go
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()}}})
|
|
}
|