0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Golang で Redis のデータを削除 (Delete)

Last updated at Posted at 2018-05-21

Golang で Redis のデータを削除します。
次のプログラムで作成したデータを削除します。
Golang で Redis のデータを作成 (Create)

プログラム

redis_delete.go
// ----------------------------------------------------------------
//
//	redis_delete.go
//
//					May/19/2018
//
// ----------------------------------------------------------------
package main
 
import (
	"fmt"
	"net"
	"os"
)

// ----------------------------------------------------------------
func main () {

	fmt.Printf ("*** 開始 ***\n")

	key_in := os.Args[1]

	fmt.Printf (key_in + "\n")

	hostname := "localhost"
	port := "6379"

	conn, err := net.Dial ("tcp",hostname + ":" + port)
	if err != nil {
		fmt.Println(err)
		return
		}

	_, err = conn.Write ([]byte("del " + key_in + "\r\n"))
	if err != nil {
		fmt.Println(err)
		return
		}

	conn.Close ()

	fmt.Printf ("*** 終了 ***\n")
}

// ----------------------------------------------------------------

実行コマンドの例

go run redis_delete.go t1856

確認したバージョン

$ go version
go version go1.19.2 linux/amd64
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?