mirror of
https://github.com/RussellChamp/advent-of-code-2021.git
synced 2026-10-27 21:52:32 +00:00
first commit
This commit is contained in:
1 parent
4c88777d7a
commit
1208efd0af
8 files changed
+342
No files matched your search
@@ -0,0 +1,36 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"os"
|
||||
)
|
||||
|
||||
func tryMe(e error) {
|
||||
if e != nil {
|
||||
fmt.Println("OH SNAP!")
|
||||
panic(e)
|
||||
}
|
||||
}
|
||||
|
||||
func files() {
|
||||
dat, err := os.ReadFile("./data.txt")
|
||||
tryMe(err)
|
||||
|
||||
fmt.Print(string(dat))
|
||||
fmt.Println("\n---")
|
||||
|
||||
f, err := os.Open("./data.txt")
|
||||
tryMe(err)
|
||||
coupleBytes := make([]byte, 10)
|
||||
num, err := f.Read(coupleBytes)
|
||||
tryMe(err)
|
||||
fmt.Println(num, string(coupleBytes))
|
||||
|
||||
reader := bufio.NewReader(f)
|
||||
rBuf, err := reader.Peek(5)
|
||||
tryMe(err)
|
||||
fmt.Println("buff reader", string(rBuf))
|
||||
|
||||
f.Close()
|
||||
}
|
||||
Reference in new issue
Block a user