Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View romanitalian's full-sized avatar
🎯
Focusing

roman romadin romanitalian

🎯
Focusing
View GitHub Profile
package main
import (
"strings"
"testing"
"time"
)
func timeIntToString(val int) string {
switch val {
// lout
log.Debugf("-------- $VAR$: %#v", $VAR$)$END$
// sout
fmt.Printf("------- rmn123 $VAR$: %+v\n", $VAR$)$END$
// fout
fmt.Println("$VAR$")
// ii
package main
import (
"log"
"net/http"
)
// go run main.go
//
// $ curl "http://127.0.0.1:8090"
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
package main
import (
"context"
"fmt"
"log"
"testing"
)
// go test -bench=. -benchmem
package main
import (
"context"
"fmt"
"log"
"time"
"github.com/go-redis/redis"
clientv3 "go.etcd.io/etcd/client/v3"
go mod tidy
go run main.go
# etcd is great
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"},
git clone -b v3.5.0 https://github.com/etcd-io/etcd.git
cd etcd
# Run etcd server.
./bin/etcd
go mod tidy
go run main.go
# redis is awesome