Advanced Programming in the UNIX® Environment Third Edition
SS 8.13
$ go build tsys.go
$ sudo chmod u+s tsys
package append_test | |
import "fmt" | |
func ExampleArrayToSlice() { | |
arr := []string{"a", "b", "c"} | |
//arr = append(arr, arr) // Compile error : cannot use arr (type []string) as type string in append | |
arr = append(arr, arr...) |
package example_test | |
import ( | |
"fmt" | |
"log" | |
"os" | |
"testing" | |
"text/scanner" | |
) |
// http://play.golang.org/p/cwMSE2imEN | |
package main | |
import ( | |
"errors" | |
"fmt" | |
"sync" | |
) | |
func main() { |
package main | |
import ( | |
"fmt" | |
"os" | |
"path/filepath" | |
) | |
func main() { | |
filepath.Walk("/tmp/", func(path string, info os.FileInfo, err error) error { |
package eg | |
func foo() string { | |
return "foo" | |
} | |
func Bar() string { | |
return "Bar" | |
} |
package stringbuild_test | |
import ( | |
"bytes" | |
"testing" | |
) | |
func StringBuild_bad() string { | |
str := "" | |
for i := 0; i < 1000; i++ { |
package main | |
import ( | |
"github.com/golang/glog" | |
) | |
func foo() { | |
glog.Info("info v1") | |
glog.Error("error v1") |
package main | |
import ( | |
"fmt" | |
) | |
func main() { | |
fmt.Println("hello") | |
} |
package main | |
import ( | |
"fmt" | |
"path/filepath" | |
) | |
func main() { | |
matches, err := filepath.Glob("*/*.go") | |
if err != nil { |