48 lines
706 B
Go
48 lines
706 B
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"os"
|
|
"os/signal"
|
|
"syscall"
|
|
|
|
valkey "github.com/redis/go-redis/v9"
|
|
)
|
|
|
|
func main() {
|
|
url := os.Args[1]
|
|
|
|
ctx, can := signal.NotifyContext(context.Background(), syscall.SIGINT)
|
|
defer can()
|
|
|
|
opt, err := valkey.ParseURL(url)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
client := valkey.NewClient(opt)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
defer client.Close()
|
|
|
|
if os.Getenv("NO_PING") == "" {
|
|
if err := client.Ping(ctx).Err(); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
foo := []any{}
|
|
for _, arg := range os.Args[2:] {
|
|
foo = append(foo, arg)
|
|
}
|
|
result := client.Do(ctx, foo...)
|
|
if err := result.Err(); err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
v, _ := result.Result()
|
|
fmt.Println(v)
|
|
}
|