Skip to content

Instantly share code, notes, and snippets.

@softprops
Last active March 7, 2024 19:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save softprops/fe780dae063fe68a8af56c14be252cab to your computer and use it in GitHub Desktop.
Save softprops/fe780dae063fe68a8af56c14be252cab to your computer and use it in GitHub Desktop.
coder pad go template
// To execute Go code, please declare a func main() in a package "main"
package main
import (
"log"
"reflect"
"time"
)
// 👇
func solution(a, b int) int {
return a + b
}
func main() {
type args struct {
a, b int
}
tests := []struct {
args args
want int
} {
{
args: args {
a: 1,
b: 2,
},
want: 1,
},
}
start := time.Now()
log.SetFlags(0) // remove goland log prefix
for _, tt := range tests {
if got := solution(tt.args.a, tt.args.b); !reflect.DeepEqual(got, tt.want) {
log.Fatalf("solution(%#v) = %#v, want %#v", tt.args, got, tt.want)
}
}
log.Printf("🐶 ✨ passed in %dms", time.Since(start).Milliseconds())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment