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" | |
) | |
type e struct{} | |
func chanErr(produceErr bool, d time.Duration, noErrChan chan e) chan e { |
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 ( | |
"flag" | |
"fmt" | |
"io" | |
"time" | |
) | |
func newReader() io.Reader { |
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 | |
// ➜ race go test -race -run TestNoRace . | |
// ok _/Users/shaun.fu/test/go/race 1.288s | |
// ➜ race go test -race -run TestRace . | |
import ( | |
"sync" | |
"testing" | |
) |
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
#!/bin/bash | |
# eru install | |
set -e | |
now=`date +%s` | |
function log() { | |
echo "[$((`date +%s` - now ))] ## $@ ##" | |
} |
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
#!/bin/bash | |
res() { | |
old=$(stty -g) | |
stty raw -echo min 0 time 5 | |
printf '\0337\033[r\033[999;999H\033[6n\0338' > /dev/tty | |
IFS='[;R' read -r _ rows cols _ < /dev/tty | |
stty "$old" |
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" | |
"unsafe" | |
) | |
func main() { | |
str := "xxx" | |
fmt.Printf("%p, %v\n", &str, str) |
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
#!/bin/bash | |
# HTTP 1.1 | |
exec 3<> /dev/tcp/ident.me/80 && \ | |
echo 'GET / HTTP/1.1' >&3 && \ | |
echo 'Host: ident.me' >&3 && \ | |
echo '' >&3 && while true;do \ | |
read -t 1 -u 3 RESP; echo $RESP; | |
[ "$RESP" == "" ] && break; | |
done && \ |
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 ( | |
"bytes" | |
"fmt" | |
"io" | |
"net/http" | |
"time" | |
"github.com/gin-gonic/gin" |
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
// https://play.golang.org/p/T8Dpm4HzX6x | |
package main | |
import "fmt" | |
func main() { | |
const ( | |
fizz = 3 | |
buzz = 5 | |
fizzbuzz = 15 |
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 ( | |
"log" | |
"os" | |
"os/signal" | |
"syscall" | |
) | |
func main() { |