reorder
This commit is contained in:
parent
23dba0980b
commit
354a9d862f
21
054-exit.go
Normal file
21
054-exit.go
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
package main // Use `os.Exit` to immediatly exit with a given
|
||||||
|
// status.
|
||||||
|
import "os"
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
defer println("!") // This `println` will never be reached.
|
||||||
|
os.Exit(3)
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
$ go run exit.go // If you run `exit.go` using `go run`, the exit
|
||||||
|
exit status 3 // will be picked up by `go` and printed.
|
||||||
|
|
||||||
|
$ go build exit.go // By building and executing a binary you can see
|
||||||
|
$ ./exit // the status in the terminal
|
||||||
|
$ echo $?
|
||||||
|
3
|
||||||
|
*/
|
||||||
|
|
||||||
|
// == todo
|
||||||
|
// discuss building before getting here
|
14
055-exits.go
14
055-exits.go
@ -1,14 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import "os"
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
os.Exit(3)
|
|
||||||
}
|
|
||||||
|
|
||||||
// $ go run xx-exit.go
|
|
||||||
// exit status 3
|
|
||||||
// $ go build xx-exit.go
|
|
||||||
// $ ./xx-exit
|
|
||||||
// $ echo $?
|
|
||||||
// 3
|
|
@ -24,7 +24,6 @@ recursion
|
|||||||
defer
|
defer
|
||||||
panic
|
panic
|
||||||
recover
|
recover
|
||||||
values
|
|
||||||
pointers
|
pointers
|
||||||
new
|
new
|
||||||
structs
|
structs
|
||||||
@ -52,7 +51,7 @@ env
|
|||||||
epoch
|
epoch
|
||||||
errors
|
errors
|
||||||
exec
|
exec
|
||||||
exits
|
exit
|
||||||
file-open
|
file-open
|
||||||
file-read
|
file-read
|
||||||
file-write
|
file-write
|
||||||
|
@ -9,8 +9,16 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"regexp"
|
"regexp"
|
||||||
"os"
|
"os"
|
||||||
|
"sort"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func minInt(a, b int) int {
|
||||||
|
if (a < b) {
|
||||||
|
return a
|
||||||
|
}
|
||||||
|
return b
|
||||||
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
// read names of source files
|
// read names of source files
|
||||||
sourceNames := make([]string, 0)
|
sourceNames := make([]string, 0)
|
||||||
@ -33,7 +41,12 @@ func main() {
|
|||||||
|
|
||||||
// sanity check two lists
|
// sanity check two lists
|
||||||
if len(sourceNames) != len(indexNames) {
|
if len(sourceNames) != len(indexNames) {
|
||||||
panic("mismatched names")
|
sort.Strings(sourceNames)
|
||||||
|
sort.Strings(indexNames)
|
||||||
|
for i := 0; i < minInt(len(sourceNames), len(indexNames)); i++ {
|
||||||
|
fmt.Printf("%s %s\n", sourceNames[i], indexNames[i])
|
||||||
|
}
|
||||||
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
// rename some stuff
|
// rename some stuff
|
||||||
|
Loading…
x
Reference in New Issue
Block a user