Added generic template for almost every day
This commit is contained in:
parent
ec4a4243ca
commit
c6150871a3
42
template.go
Normal file
42
template.go
Normal file
@ -0,0 +1,42 @@
|
||||
package main
|
||||
|
||||
import()
|
||||
|
||||
// Parallel code, global vars
|
||||
type Nodes struct {
|
||||
mu sync.Mutex
|
||||
variable type
|
||||
}
|
||||
|
||||
func check(e error) {
|
||||
if e != nil {
|
||||
panic(e)
|
||||
}
|
||||
}
|
||||
|
||||
func PrintAndWait(x ...any) {
|
||||
fmt.Print(x...)
|
||||
fmt.Scanln()
|
||||
}
|
||||
// use defer timer("funcname")() when the function you want to
|
||||
// test starts
|
||||
func timer(name string) func() {
|
||||
start := time.Now()
|
||||
return func() {
|
||||
fmt.Printf("%s took %v\n", name, time.Since(start))
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
file, err := os.Open("./inputs")
|
||||
check(err)
|
||||
defer file.Close()
|
||||
|
||||
lines := make([]string, 0)
|
||||
|
||||
scanner := bufio.NewScanner(file)
|
||||
for scanner.Scan() {
|
||||
lines = append(lines, scanner.Text())
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user