Slide 34
Slide 34 text
12:50 PM-1:05 PM
リアルタイムのフラグ管理
main.go
func main() {
// Use flagd as the OpenFeature provider
openfeature.SetProvider(flagd.NewProvider())
// Initialize OpenFeature client
client := openfeature.NewClient("GoStartApp")
// Initialize Go Gin
engine := gin.Default()
// Setup a simple endpoint
engine.GET("/hello", func(c *gin.Context) {
// Evaluate welcome-message feature flag
welcomeMessage, _ := client.BooleanValue(
context.Background(), "welcome-message", false, openfeature.EvaluationContext{},
)
if welcomeMessage {
c.JSON(http.StatusOK, gin.H{"message": newWelcomeMessage})
return
} else {
c.JSON(http.StatusOK, gin.H{"message": defaultMessage})
return
}
})
Client と Provider(flagd) 導入
Sample https://github.com/koudaiii/gostart