Merge branch 'possible-patch/error-checking' of https://github.com/andrew-field/gobyexample into andrew-field-possible-patch/error-checking

This commit is contained in:
Mark McGranaghan
2020-04-10 17:53:11 -07:00
7 changed files with 16 additions and 11 deletions

View File

@@ -53,6 +53,7 @@ func main() {
// `TempFile`'s, but it returns a directory *name*
// rather than an open file.
dname, err := ioutil.TempDir("", "sampledir")
check(err)
fmt.Println("Temp dir name:", dname)
defer os.RemoveAll(dname)

View File

@@ -1,2 +1,2 @@
371689e72c46daa43eefbd9b9f4eaa3c490e7fd2
yKWE4QTsYQr
cc4755e23cb4ba3c0e0ef5554ec9e9477372422a
nMpjCsALS6P

View File

@@ -40,6 +40,7 @@ func main() {
// A `WriteString` is also available.
n3, err := f.WriteString("writes\n")
check(err)
fmt.Printf("wrote %d bytes\n", n3)
// Issue a `Sync` to flush writes to stable storage.
@@ -49,6 +50,7 @@ func main() {
// to the buffered readers we saw earlier.
w := bufio.NewWriter(f)
n4, err := w.WriteString("buffered\n")
check(err)
fmt.Printf("wrote %d bytes\n", n4)
// Use `Flush` to ensure all buffered operations have

View File

@@ -1,2 +1,2 @@
d4f19bc0168674b17551bbf55bab7af989452d0e
8kx-qYUXBpA
314a0074840e22b328b6412130c17b9bea53c9c9
fQ7sd4gXv0F