Skip to content

Commit

Permalink
Fix example in godoc (#1480)
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Poignant <[email protected]>
  • Loading branch information
thomaspoignant authored Jan 27, 2024
1 parent 6770267 commit 9191735
Showing 1 changed file with 26 additions and 20 deletions.
46 changes: 26 additions & 20 deletions package_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,36 @@
// The ffclient package provides the entry point - initialization and the basic
// method to get your flags value.
//
// Before using the module you need to initialized it this way:
//
// func main() {
// err := ffclient.Init(ffclient.Config{
// PollingInterval: 3 * time.Second,
// HTTPRetriever: &httpretriever.Retriever{
// URL: "http://example.com/flag-config.yaml",
// },
// })
// defer ffclient.Close()
// ...
// Before using the module you need to initialize it this way:
//
// import (
// ffclient "github.com/thomaspoignant/go-feature-flag"
// "github.com/thomaspoignant/go-feature-flag/retriever/httpretriever"
// ...
// )
//
// func main() {
// err := ffclient.Init(ffclient.Config{
// PollingInterval: 3 * time.Second,
// Retriever: &httpretriever.Retriever{
// URL: "https://code.gofeatureflag.org/blob/main/testdata/flag-config.yaml",
// },
// })
// defer ffclient.Close()
// ...
//
// This example will load a file from an HTTP endpoint and will refresh the flags every 3 seconds.
//
// Now you can evaluate your flags anywhere in your code.
//
// func main() {
// ...
// user := ffcontext.NewEvaluationContext("user-unique-key")
// hasFlag, _ := ffclient.BoolVariation("test-flag", user, false)
// if hasFlag {
// //flag "test-flag" is true for the user
// } else {
// // flag "test-flag" is false for the user
// ...
// evaluationContext := ffcontext.NewEvaluationContext("user-unique-key")
// hasFlag, _ := ffclient.BoolVariation("test-flag", evaluationContext, false)
// if hasFlag {
// //flag "test-flag" is true for the user
// } else {
// // flag "test-flag" is false for the user
// }
// ...
// }
// ...
package ffclient

0 comments on commit 9191735

Please sign in to comment.