1
0
mirror of https://github.com/redis/go-redis.git synced 2025-10-27 18:15:32 +03:00
Files
go-redis/doctests
iliya 4bc183618c chore(tests): Refactor tests for idiomatic Go and minor improvements (#3561)
* all: Refactor tests for idiomatic Go and minor improvements

Replaced redundant 'for key, _' with 'for key' in map iterations for clarity in doctests/cmds_hash_test.go. Updated time measurement from time.Now().Sub to time.Since in hset_benchmark_test.go for idiomatic Go usage. Simplified variadic argument types from interface{} to any and removed unused min function in maintnotifications/e2e/utils_test.go.

* maintnotifications/e2e/utils_test: Update variadic args type in printLog function

Changed the variadic argument type in printLog from 'any' to 'interface{}' for compatibility and consistency with standard Go practices.
2025-10-25 03:29:08 +03:00
..
2025-06-06 16:25:35 +03:00

Command examples for redis.io

These examples appear on the Redis documentation site as part of the tabbed examples interface.

How to add examples

  • Create a Go test file with a meaningful name in the current folder.
  • Create a single method prefixed with Example and write your test in it.
  • Determine the id for the example you're creating and add it as the first line of the file: // EXAMPLE: set_and_get.
  • We're using the Testable Examples feature of Go to test the desired output has been written to stdout.

Special markup

See https://github.com/redis-stack/redis-stack-website#readme for more details.

How to test the examples

  • Start a Redis server locally on port 6379
  • CD into the doctests directory
  • Run go test to test all examples in the directory.
  • Run go test filename.go to test a single file