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 | |
| # Usage examples: | |
| # ./note.sh # Show all notes with numbers | |
| # ./note.sh "Buy milk" # Add new note | |
| # ./note.sh "TODO: Fix bugs" # Add todo note | |
| # ./note.sh -d 5 # Delete note number 5 | |
| # ./note.sh -cl # Clear all notes (with confirmation) | |
| # ./note.sh -h # Show this help message | |
| # |
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 ( | |
| "strings" | |
| "testing" | |
| "time" | |
| ) | |
| func timeIntToString(val int) string { | |
| switch val { |
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
| // lout | |
| log.Debugf("-------- $VAR$: %#v", $VAR$)$END$ | |
| // sout | |
| fmt.Printf("------- rmn123 $VAR$: %+v\n", $VAR$)$END$ | |
| // fout | |
| fmt.Println("$VAR$") | |
| // ii |
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" | |
| "net/http" | |
| ) | |
| // go run main.go | |
| // | |
| // $ curl "http://127.0.0.1:8090" |
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
| go test -bench=. -benchmem | |
| BenchmarkRedisSet-8 1526 802456 ns/op 249 B/op 9 allocs/op | |
| BenchmarkRedisGet-8 1552 818410 ns/op 196 B/op 7 allocs/op | |
| BenchmarkEtcdSet-8 80 27729002 ns/op 14010 B/op 124 allocs/op | |
| BenchmarkEtcdGet-8 9590 125109 ns/op 7070 B/op 125 allocs/op |
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 ( | |
| "context" | |
| "fmt" | |
| "log" | |
| "testing" | |
| ) | |
| // go test -bench=. -benchmem |
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 ( | |
| "context" | |
| "fmt" | |
| "log" | |
| "time" | |
| "github.com/go-redis/redis" | |
| clientv3 "go.etcd.io/etcd/client/v3" |
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
| go mod tidy | |
| go run main.go | |
| # etcd is great |
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" | |
| clientv3 "go.etcd.io/etcd/client/v3" | |
| ) | |
| func NewEtcdClient() (*clientv3.Client, error) { | |
| cl, err := clientv3.New(clientv3.Config{ | |
| Endpoints: []string{"localhost:2379"}, |
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
| git clone -b v3.5.0 https://github.com/etcd-io/etcd.git | |
| cd etcd | |
| # Run etcd server. | |
| ./bin/etcd |
NewerOlder