This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"os" | |
"log" | |
"time" | |
) | |
func main() { | |
logfile, err := os.OpenFile("test.log", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"time" | |
) | |
// The timeout handler. | |
func ontimeout(t time.Time) { | |
fmt.Println("[timeout] ", t) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"os" | |
"fmt" | |
"encoding/json" | |
) | |
type PackageInfo struct { | |
Name string |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"regexp" | |
) | |
func main() { | |
str := "Ruby 2.0 is the 2nd major release of Ruby" | |
re, err := regexp.Compile("[.\\d]+") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* This is a bidirectional router that shows how to implement | |
* I/O multiplexing in Go. The function is similar to netcat. | |
* Test this program in terminal: | |
* | |
* $ go run simplerouter.go | |
* GET / HTTP/1.0<CR> | |
* <CR> | |
* HTTP/1.0 302 Found | |
* ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* This is a bidirectional router that shows how to implement | |
* I/O multiplexing in Go. The function is similar to netcat. | |
* Test this program in terminal: | |
* | |
* $ go run simplerouter.go | |
* GET / HTTP/1.0<CR> | |
* <CR> | |
* HTTP/1.0 302 Found | |
* ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* This is a simple netcat implementation in go. | |
* Test this program in terminal: | |
* | |
* $ go run simplerouter.go | |
* GET / HTTP/1.0<CR> | |
* <CR> | |
* HTTP/1.0 302 Found | |
* ... | |
* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"time" | |
) | |
func work(ch chan int) { | |
time.Sleep(5000 * time.Millisecond) | |
ch <- 12345 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"io" | |
"os" | |
"fmt" | |
"log" | |
"net" | |
"time" | |
"strings" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"os" | |
"os/signal" | |
"syscall" | |
) | |
func main() { |