Last active
March 7, 2024 19:03
-
-
Save softprops/fe780dae063fe68a8af56c14be252cab to your computer and use it in GitHub Desktop.
coder pad go template
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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