index work

This commit is contained in:
Mark McGranaghan 2012-09-23 17:45:04 -07:00
parent 997fcafeca
commit e4b083d49b
78 changed files with 30 additions and 56 deletions

View File

@ -1,21 +0,0 @@
// ## File Open
package main
import "os"
import "fmt"
func main() {
file, err := os.Open("xx-file-open.go")
if err != nil {
panic(err)
}
defer file.Close()
stat, err := file.Stat()
if err != nil {
panic(err)
}
fmt.Println("Program has", stat.Size(), "bytes")
}

View File

@ -1,4 +1,4 @@
// ## File Read
// ## Reading files
package main
@ -12,3 +12,6 @@ func main() {
}
fmt.Print(string(contents))
}
// todo: streaming reads

View File

@ -1,4 +1,4 @@
// ## File Write
// ## Writing Files
package main
@ -12,3 +12,5 @@ func main() {
defer file.Close()
file.WriteString("contents\n")
}
// todo: streaming writes

View File

@ -1,4 +1,4 @@
// ## Env
// ## Environment Variables
package main

View File

@ -0,0 +1,6 @@
$ go run environment-variables.go
HOME
PATH
PWD
...
bar

View File

@ -1,6 +0,0 @@
$ go run env.go
HOME
PATH
PWD
...
bar

View File

@ -1,8 +1,9 @@
// ## Spawn
// ## Spawning Processes
package main
import ("os/exec"; "fmt")
import "os/exec"
import "fmt"
func main() {
cmd := exec.Command("ls", "-a", "-l")

View File

@ -1,6 +1,6 @@
$ go run spawn.go
$ go run spawning-processes.go
Files:
total 8
drwxr-xr-x 3 mmcgrana staff 102 Sep 23 11:35 .
drwxr-xr-x 101 mmcgrana staff 3434 Sep 23 11:25 ..
-rw-r--r--@ 1 mmcgrana staff 241 Sep 23 11:37 spawn.go
-rw-r--r--@ 1 mmcgrana staff 241 Sep 23 11:37 spawning-processes.go

View File

@ -1,4 +1,4 @@
// ## Exec
// ## Exec'ing Processes
package main
@ -16,3 +16,5 @@ func main() {
panic(execErr)
}
}
// todo: note lack of fork

View File

@ -18,3 +18,5 @@ func main() {
fmt.Println("Awaiting signal")
<- d
}
// todo: sending signals?

View File

@ -1,11 +0,0 @@
package main
import "fmt"
import "os/user"
func main() {
me, _ := user.Current()
fmt.Println(me)
root, _ := user.Lookup("root")
fmt.Println(root)
}

View File

@ -1,3 +0,0 @@
$ go run users.go
&{501 20 mmcgrana Mark McGranaghan /Users/mmcgrana}
&{0 0 root System Administrator /var/root}

View File

@ -70,18 +70,17 @@ sha1-hashes
~ base64-encoding
# systems programming
file-open
file-read
file-write
reading-files
writing-files
~ standard-streams
command-line-arguments
command-line-flags
env
environment-variables
spawning-processes
execing-processes
signals
exit
spawn
exec
reading-input
users
line-filter
tcp server