fix: fatalln -> fatal
This commit is contained in:
@ -17,14 +17,14 @@ func main() {
|
|||||||
// First encode products as JSON:
|
// First encode products as JSON:
|
||||||
data, err := encode()
|
data, err := encode()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalln(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
fmt.Println(string(data))
|
fmt.Println(string(data))
|
||||||
|
|
||||||
// Then decode them back from JSON:
|
// Then decode them back from JSON:
|
||||||
l, err := decode(data)
|
l, err := decode(data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalln(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Let the list value print itself:
|
// Let the list value print itself:
|
||||||
@ -46,7 +46,7 @@ Summary:
|
|||||||
- There are several other functions in the strconv package for other primitive types as well.
|
- There are several other functions in the strconv package for other primitive types as well.
|
||||||
- Do not make unnecessary string <-> []byte conversions.
|
- Do not make unnecessary string <-> []byte conversions.
|
||||||
|
|
||||||
- log.Fatalln() can print the given error message and terminate the program.
|
- log.Fatal() can print the given error message and terminate the program.
|
||||||
- Use it only from the main(). Do not use it in other functions.
|
- Use it only from the main(). Do not use it in other functions.
|
||||||
- main() is should be the main driver of a program.
|
- main() is should be the main driver of a program.
|
||||||
*/
|
*/
|
||||||
|
@ -21,31 +21,31 @@ func main() {
|
|||||||
// #1: reads from the standard input
|
// #1: reads from the standard input
|
||||||
// ------------------------------------------------
|
// ------------------------------------------------
|
||||||
// if err := read(os.Stdin); err != nil {
|
// if err := read(os.Stdin); err != nil {
|
||||||
// log.Fatalln(err)
|
// log.Fatal(err)
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// #2: writes to the standard output
|
// #2: writes to the standard output
|
||||||
// ------------------------------------------------
|
// ------------------------------------------------
|
||||||
// buf := []byte("hi!\n")
|
// buf := []byte("hi!\n")
|
||||||
// if err := write(os.Stdout, buf); err != nil {
|
// if err := write(os.Stdout, buf); err != nil {
|
||||||
// log.Fatalln(err)
|
// log.Fatal(err)
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// #2b: reads the entire file content into memory.
|
// #2b: reads the entire file content into memory.
|
||||||
// ------------------------------------------------
|
// ------------------------------------------------
|
||||||
// buf, err := ioutil.ReadFile("alice.txt")
|
// buf, err := ioutil.ReadFile("alice.txt")
|
||||||
// if err != nil {
|
// if err != nil {
|
||||||
// log.Fatalln(err)
|
// log.Fatal(err)
|
||||||
// }
|
// }
|
||||||
// if err := write(os.Stdout, buf); err != nil {
|
// if err := write(os.Stdout, buf); err != nil {
|
||||||
// log.Fatalln(err)
|
// log.Fatal(err)
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// #3: reads and writes with 32KB of memory
|
// #3: reads and writes with 32KB of memory
|
||||||
// no matter how large the source data is.
|
// no matter how large the source data is.
|
||||||
// ------------------------------------------------
|
// ------------------------------------------------
|
||||||
if err := ioCopy(os.Stdout, os.Stdin); err != nil {
|
if err := ioCopy(os.Stdout, os.Stdin); err != nil {
|
||||||
log.Fatalln(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,10 +22,10 @@ func main() {
|
|||||||
|
|
||||||
p, err := fromFile(os.Args[1])
|
p, err := fromFile(os.Args[1])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalln(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := p.Run(); err != nil {
|
if err := p.Run(); err != nil {
|
||||||
log.Fatalln(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,10 +27,10 @@ func main() {
|
|||||||
g.Group(p.Value())
|
g.Group(p.Value())
|
||||||
}
|
}
|
||||||
if err := p.Err(); err != nil {
|
if err := p.Err(); err != nil {
|
||||||
log.Fatalln(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := report.Text(os.Stdout, g.Records()); err != nil {
|
if err := report.Text(os.Stdout, g.Records()); err != nil {
|
||||||
log.Fatalln(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user