move h2 out of source files

This commit is contained in:
Mark McGranaghan
2012-10-09 18:31:28 -07:00
parent 571a58ece4
commit bc39dbc769
89 changed files with 107 additions and 274 deletions

View File

@@ -1,5 +1,3 @@
// ## Arrays
package main
import "fmt"

View File

@@ -1,5 +1,3 @@
// ## Base64 Encoding
package main
import b64 "encoding/base64"

View File

@@ -1,5 +1,3 @@
// ## Basic Authentication
package main
import (

View File

@@ -1,5 +1,3 @@
// ## Bytes
package main
import "fmt"

View File

@@ -1,5 +1,3 @@
// ## Canonical Hosts
package main
import "net/http"

View File

@@ -1,5 +1,3 @@
// ## Channel Buffering
package main
import "fmt"

View File

@@ -1,5 +1,3 @@
// ## Channel Directions
package main
import "fmt"

View File

@@ -1,5 +1,3 @@
// ## Channels
package main
import "fmt"

View File

@@ -1,5 +1,3 @@
// ## Closing Channels
package main
import "fmt"

View File

@@ -1,5 +1,3 @@
// ## Closures
package main
import "fmt"

View File

@@ -1,5 +1,3 @@
// ## Collection Functions
package main
import "strings"
@@ -92,4 +90,4 @@ func main() {
fmt.Println()
}
// todo: generics
// todo: note no generics

View File

@@ -1,5 +1,3 @@
// ## Command Line Arguments
// Use `os.Args` to access command-line arguments and
// the name of the program.
package main

View File

@@ -1,5 +1,3 @@
// ## Command Line Flags
package main
import "flag"

View File

@@ -1,5 +1,3 @@
// ## Concurrent Goroutines
package main
import "time"

View File

@@ -1,5 +1,3 @@
// ## Constants
package main
import "fmt"

View File

@@ -1,5 +1,3 @@
// ## Defer
package main
import "fmt"

View File

@@ -1,5 +1,3 @@
// ## Elapsed Time
package main
import "time"

View File

@@ -1,5 +1,3 @@
// ## Embedding
package main
import "math"

View File

@@ -1,5 +1,3 @@
// ## Environment Variables
package main
// Use the `os` package to list, set, and get environment

View File

@@ -1,5 +1,3 @@
// ## Epochs
// A common requirement in programms is getting the number
// of seconds, milliseconds, or nanoseconds since the Unix
// epoch. Here's how to do it in Go.

View File

@@ -1,5 +1,3 @@
// ## Errors
package main
import (

View File

@@ -1,5 +1,3 @@
// ## Exec'ing Processes
// In the previous chapter we looked at spawning external
// process. We do this when we need the functionality
// of another process accessable to a running Go process.

View File

@@ -1,5 +1,3 @@
// ## Exit
// Use `os.Exit` to immediatly exit with a given
// status.

View File

@@ -1,5 +1,3 @@
// ## For
// `for` is Go's only looping construct. Here are
// two common forms.
package main

View File

@@ -1,5 +1,3 @@
// ## Functions
// Funcations are critical in Go as in any other language.
// We'll look at some basic examples first.

View File

@@ -1,5 +1,3 @@
// ## Goroutines
package main
import "fmt"

View File

@@ -1,5 +1,3 @@
// ## Graceful Shutdown
package main
import (
@@ -96,8 +94,5 @@ func main() {
}
}
// todo: clean up logging
// todo: limit shutdown time
// todo: pull in work from gobyexample-server
// todo: factor out to cut-and-pastable against normal app
// todo: credit http://blog.nella.org/?p=879
// todo: comment about tcp servers

View File

@@ -1,5 +1,3 @@
// ## Hello Web
package main
import "net/http"

View File

@@ -1,5 +1,3 @@
// ## Hello World
// Our first program will print the classic "Hello world"`
// message. Here's the full source code.
package main

View File

@@ -1,5 +1,3 @@
// ## HTTP Client
package main
import "net/http"

View File

@@ -1,5 +1,3 @@
// ## HTTPS Client
package main
import "net/http"

View File

@@ -1,5 +1,3 @@
// ## HTTPS Servers
package main
import "net/http"

View File

@@ -1,6 +1,5 @@
// ## If/Else
// If/else in Go is straight-forward.
// If/else in go is straight-forward
package main
import "fmt"

View File

@@ -1,2 +0,0 @@
$ go run inline-assignment.go
Hello assignment

View File

@@ -1,5 +1,3 @@
// ## Interfaces
package main
import "fmt"

View File

@@ -1,5 +1,3 @@
// ## JSON
package main
import "encoding/json"

View File

@@ -1,5 +1,3 @@
// ## Line Filters
// A _line filter_ is a common type of program that reads
// input on stdin, processes it, and then prints some
// derived result to stdout. `grep` and `sed` are common

View File

@@ -1,5 +1,3 @@
// ## Maps
// Maps are Go's built-in associative data type (sometimes
// called "hashes" or "dicts" in other languages).

View File

@@ -1,5 +1,3 @@
// ## Methods
package main
import "fmt"

View File

@@ -1,5 +1,3 @@
// ## Middleware
package main
import "net/http"

View File

@@ -1,5 +1,3 @@
// ## Multiple Return Values
// Go has built-in support for multiple return values.
// This feature is used often in idiomatic Go, for example
// to return both result and error values from a function.

View File

@@ -1,5 +1,3 @@
// ## New
package main
import "fmt"

View File

@@ -1,5 +1,3 @@
// ## Non-blocking Channel Operations
package main
import "fmt"

View File

@@ -1,5 +1,3 @@
// ## Number Parsing
package main
// Package `strconv` provides the number parsing.

View File

@@ -1,5 +1,3 @@
// ## OK Guards
package main
import "fmt"

View File

@@ -1,5 +1,3 @@
// ## Panic
// A `panic` means something went unexpectedly wrong.
// Mostly we use it to fail fast on errors that
// shouldn't occur during normal operation.

View File

@@ -1,5 +1,3 @@
// ## Pointers
package main
import "fmt"

View File

@@ -1,5 +1,3 @@
// ## Postgres
package main
import _ "github.com/bmizerany/pq"

View File

@@ -1,5 +1,3 @@
// ## Random Numbers
package main
// The `math/rand` package provides psuedo-random

View File

@@ -1,5 +1,3 @@
// ## Range
package main
import "fmt"

View File

@@ -1,4 +1,3 @@
// ## Rate Limiting
package main
import "time"

View File

@@ -1,5 +1,3 @@
// ## Reading files
package main
import "io/ioutil"

View File

@@ -1,5 +1,3 @@
// ## Recursion
package main
import "fmt"

View File

@@ -1,5 +1,3 @@
// ## Redis
package main
import "github.com/fzzbt/radix/redis"

View File

@@ -1,5 +1,3 @@
// ## Regexs
package main
import "regexp"

View File

@@ -1,5 +1,3 @@
// ## Request Logging
package main
import "net/http"

View File

@@ -1,5 +1,3 @@
// ## HTTP Server Routing
package main
import "github.com/bmizerany/pat"

View File

@@ -1,5 +1,3 @@
// ## Responses
package main
import "net/http"

View File

@@ -1,5 +1,3 @@
// ## Scatter-Gather
package main
import "sync"

View File

@@ -1,5 +1,3 @@
// ## Select
package main
import "time"

View File

@@ -1,5 +1,3 @@
// ## SHA1 Hashes
package main
// Package `crypto/sha1` computes SHA1 hashes.

View File

@@ -1,11 +1,9 @@
// ## Inline Assignment
package main
import "fmt"
func main() {
// `x := val` is shorthand for `var x type = val`.
x := "Hello assignment"
x := "Hello var"
fmt.Println(x)
}

View File

@@ -0,0 +1,2 @@
$ go run short-declarations.go
Hello var

View File

@@ -1,5 +1,3 @@
// ## Signals
// Sometines we'd like our Go programs to intelligently
// handle Unix signals. For example, we might want a
// server to gracefully shutdown when it receives a

View File

@@ -1,5 +1,3 @@
// ## Slices
package main
import "fmt"

View File

@@ -1,5 +1,3 @@
// ## Sorting by Functions
// Sometimes we'll want to sort a collection by something
// other than its natural order. For example, suppose we
// wanted to sort strings by their length instead of

View File

@@ -1,5 +1,3 @@
// ## Sorting
// Go's `sort` package implements sorting for builtins
// and user-defined types. We'll look at sorting for
// builtins first.

View File

@@ -1,5 +1,3 @@
// ## Spawning Processes
// Sometimes our Go programs need to spawn other, non-Go
// processes. For example, the syntax highlighting in this
// book is implementing by spawning a [`pygmentize`]()

View File

@@ -1,5 +1,3 @@
// ## State Goroutine
package main
import "fmt"

View File

@@ -1,5 +1,3 @@
// ## State Mutex
package main
import "fmt"
@@ -64,3 +62,5 @@ func main() {
finalOpCount := atomic.LoadInt64(&opCount)
fmt.Println(finalOpCount)
}
// todo: "State with Mutexes?"

View File

@@ -1,5 +1,3 @@
// ## Static Content
package main
import "net/http"

View File

@@ -1,5 +1,3 @@
// ## String Formatting
package main
import "fmt"

View File

@@ -1,5 +1,3 @@
// ## String Functions
// The standard library's `strings` package provides many
// useful string-related functions.

View File

@@ -1,5 +1,3 @@
// ## Structs
package main
import "fmt"

View File

@@ -1,5 +1,3 @@
// ## Switch
// Switch statements allow...
package main

View File

@@ -1,5 +1,3 @@
// ## Synchronization
// We can use channels to synchronize execution
// accross goroutines. Here's an example of waiting
// for another goroutine to finish.

View File

@@ -1,5 +1,3 @@
// ## Tickers
// [Timers](timers) are for when you want to do
// something once in the future - tickers are for when you
// want to do something repeatedly at regular intervals.

View File

@@ -1,5 +1,3 @@
// ## Time
package main
import "time"

View File

@@ -1,5 +1,3 @@
// ## Timeouts
package main
import "time"

View File

@@ -1,5 +1,3 @@
// ## Timers
// We often want to execute Go code at some point in the
// future, or repeatedly at some interval. Go's built-in
// timer and ticker features make both of these tasks

View File

@@ -1,5 +1,3 @@
// ## URLs
package main
import "fmt"

View File

@@ -1,5 +1,3 @@
// ## Values
// Go has various value types, including strings,
// different types of numbers, booleans, etc.
package main

View File

@@ -1,5 +1,3 @@
// ## Varadic Functions
// Varadic functions can be called with any number of
// trailing arguments. This is useful if you don't know
// number of arguments that will be needed for a function

View File

@@ -1,5 +1,3 @@
// ## Variables
package main
import "fmt"

View File

@@ -1,5 +1,3 @@
// ## Worker Pools
package main
import "time"

View File

@@ -1,11 +1,9 @@
// ## Writing Files
package main
import "os"
func main() {
file, err := os.Create("xx-file-write.txt")
file, err := os.Create("writing-files.txt")
if err != nil {
panic(err)
}