Add Go support

This commit is contained in:
akp 2023-12-13 00:58:06 +00:00
parent 2096f0eeaa
commit 7384395c35
No known key found for this signature in database
GPG key ID: CF8D58F3DEB20755
2 changed files with 45 additions and 0 deletions

1
aoc
View file

@ -16,6 +16,7 @@ CHALLENGES_DIR = "challenges"
SAMPLE_TEST_JSON = "{}" SAMPLE_TEST_JSON = "{}"
RUNNERS = { RUNNERS = {
"py": ["python3"], "py": ["python3"],
"go": ["go", "run"],
} }

44
templates/main.go Normal file
View file

@ -0,0 +1,44 @@
package main
import (
"fmt"
"io"
"os"
"strings"
)
func parse(instr string) any {
return nil
}
func one(instr string) int {
return -1
}
func two(instr string) int {
return -1
}
func main() {
if len(os.Args) < 2 || !(os.Args[1] == "1" || os.Args[1] == "2") {
debug("Missing day argument")
os.Exit(1)
}
inp, err := io.ReadAll(os.Stdin)
if err != nil {
panic(err)
}
inpStr := strings.TrimSpace(string(inp))
switch os.Args[1] {
case "1":
fmt.Println(one(inpStr))
case "2":
fmt.Println(two(inpStr))
}
}
func debug(f string, sub ...any) {
fmt.Fprintf(os.Stderr, f, sub...)
}