Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Object flag not generated #30

Open
thomaspoignant opened this issue Oct 10, 2024 · 1 comment
Open

Object flag not generated #30

thomaspoignant opened this issue Oct 10, 2024 · 1 comment

Comments

@thomaspoignant
Copy link
Member

thomaspoignant commented Oct 10, 2024

When trying to generate the code for the sample manifest in sample/sample_manifest.json the code is well generated except for the object flag (themeCustomization).

Step to reproduce

  1. Clone the repository
  2. Build the cli
     go build .
  3. Run the command
     ./codegen generate go --package_name completion --flag_manifest_path=./sample/sample_manifest.json --output_path=./completion.go
  4. Output is
    package completion
    
    import "context"
    
    import (
    	"github.com/open-feature/go-sdk/openfeature"
    )
    
    type BooleanProvider func(ctx context.Context) (bool, error)
    type FloatProvider func(ctx context.Context) (float64, error)
    type IntProvider func(ctx context.Context) (int64, error)
    type StringProvider func(ctx context.Context) (string, error)
    
    var client *openfeature.Client = nil
    
    // Controls whether Feature A is enabled.
    var EnableFeatureA = struct {
    	Value BooleanProvider
    }{
    	Value: func(ctx context.Context) (bool, error) {
    		return client.BooleanValue(ctx, "enableFeatureA", false, openfeature.EvaluationContext{})
    	},
    }
    
    // Maximum allowed length for usernames.
    var UsernameMaxLength = struct {
    	Value IntProvider
    }{
    	Value: func(ctx context.Context) (int64, error) {
    		return client.IntValue(ctx, "usernameMaxLength", 50, openfeature.EvaluationContext{})
    	},
    }
    
    // The message to use for greeting users.
    var GreetingMessage = struct {
    	Value StringProvider
    }{
    	Value: func(ctx context.Context) (string, error) {
    		return client.StringValue(ctx, "greetingMessage", "Hello there!", openfeature.EvaluationContext{})
    	},
    }
    
    // Discount percentage applied to purchases.
    var DiscountPercentage = struct {
    	Value FloatProvider
    }{
    	Value: func(ctx context.Context) (float64, error) {
    		return client.FloatValue(ctx, "discountPercentage", 0.15, openfeature.EvaluationContext{})
    	},
    }
    
    func init() {
    	client = openfeature.NewClient("github.com/thomaspoignant/go-feature-flag")
    }
@beeme1mr
Copy link
Member

I believe this is intentional for now, but we should add support soon.

https://github.com/open-feature/codegen/blob/main/internal/generate/plugins/golang/golang.go#L36

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants