diff --git a/example/getter_config/config.go b/example/getter_config/config.go index 00be738..3e43b18 100644 --- a/example/getter_config/config.go +++ b/example/getter_config/config.go @@ -8,58 +8,58 @@ import ( "time" ) -type AppConfig struct{} +type appConfig struct{} -type AppLoggingConfig struct{} +type apploggingConfig struct{} -type AppLoggingRotationConfig struct{} +type apploggingrotationConfig struct{} -type CacheConfig struct{} +type cacheConfig struct{} -type CacheRedisConfig struct{} +type cacheredisConfig struct{} -type DatabaseConfig struct{} +type databaseConfig struct{} -type DatabasePoolConfig struct{} +type databasepoolConfig struct{} -type EndpointsItem struct{} +type endpointsItem struct{} -type FeaturesItem struct{} +type featuresItem struct{} -type ServerConfig struct{} +type serverConfig struct{} -type ServiceConfig struct{} +type serviceConfig struct{} -func (AppConfig) Logging() AppLoggingConfig { - return AppLoggingConfig{} +func (appConfig) Logging() apploggingConfig { + return apploggingConfig{} } -func (AppLoggingConfig) File() string { +func (apploggingConfig) File() string { if v := os.Getenv("CONFIG_APP_LOGGING_FILE"); v != "" { return v } return "/var/log/app.log" } -func (AppLoggingConfig) Format() string { +func (apploggingConfig) Format() string { if v := os.Getenv("CONFIG_APP_LOGGING_FORMAT"); v != "" { return v } return "json" } -func (AppLoggingConfig) Level() string { +func (apploggingConfig) Level() string { if v := os.Getenv("CONFIG_APP_LOGGING_LEVEL"); v != "" { return v } return "info" } -func (AppLoggingConfig) Rotation() AppLoggingRotationConfig { - return AppLoggingRotationConfig{} +func (apploggingConfig) Rotation() apploggingrotationConfig { + return apploggingrotationConfig{} } -func (AppLoggingRotationConfig) Compress() bool { +func (apploggingrotationConfig) Compress() bool { if v := os.Getenv("CONFIG_APP_LOGGING_ROTATION_COMPRESS"); v != "" { if b, err := strconv.ParseBool(v); err == nil { return b @@ -68,7 +68,7 @@ func (AppLoggingRotationConfig) Compress() bool { return true } -func (AppLoggingRotationConfig) MaxAge() int64 { +func (apploggingrotationConfig) MaxAge() int64 { if v := os.Getenv("CONFIG_APP_LOGGING_ROTATION_MAX_AGE"); v != "" { if i, err := strconv.ParseInt(v, 10, 64); err == nil { return i @@ -77,7 +77,7 @@ func (AppLoggingRotationConfig) MaxAge() int64 { return 30 } -func (AppLoggingRotationConfig) MaxSize() int64 { +func (apploggingrotationConfig) MaxSize() int64 { if v := os.Getenv("CONFIG_APP_LOGGING_ROTATION_MAX_SIZE"); v != "" { if i, err := strconv.ParseInt(v, 10, 64); err == nil { return i @@ -86,21 +86,21 @@ func (AppLoggingRotationConfig) MaxSize() int64 { return 100 } -func (AppConfig) Name() string { +func (appConfig) Name() string { if v := os.Getenv("CONFIG_APP_NAME"); v != "" { return v } return "myservice" } -func (AppConfig) Version() string { +func (appConfig) Version() string { if v := os.Getenv("CONFIG_APP_VERSION"); v != "" { return v } return "1.0.0" } -func (CacheConfig) Enabled() bool { +func (cacheConfig) Enabled() bool { if v := os.Getenv("CONFIG_CACHE_ENABLED"); v != "" { if b, err := strconv.ParseBool(v); err == nil { return b @@ -109,7 +109,7 @@ func (CacheConfig) Enabled() bool { return true } -func (CacheConfig) MaxEntries() int64 { +func (cacheConfig) MaxEntries() int64 { if v := os.Getenv("CONFIG_CACHE_MAX_ENTRIES"); v != "" { if i, err := strconv.ParseInt(v, 10, 64); err == nil { return i @@ -118,25 +118,25 @@ func (CacheConfig) MaxEntries() int64 { return 10000 } -func (CacheConfig) Outputs() []string { +func (cacheConfig) Outputs() []string { if v := os.Getenv("CONFIG_CACHE_OUTPUTS"); v != "" { // Array overrides not supported via env vars } return []string{"stdout", "file"} } -func (CacheConfig) Redis() CacheRedisConfig { - return CacheRedisConfig{} +func (cacheConfig) Redis() cacheredisConfig { + return cacheredisConfig{} } -func (CacheRedisConfig) Addr() string { +func (cacheredisConfig) Addr() string { if v := os.Getenv("CONFIG_CACHE_REDIS_ADDR"); v != "" { return v } return "localhost:6379" } -func (CacheRedisConfig) Db() int64 { +func (cacheredisConfig) Db() int64 { if v := os.Getenv("CONFIG_CACHE_REDIS_DB"); v != "" { if i, err := strconv.ParseInt(v, 10, 64); err == nil { return i @@ -145,14 +145,14 @@ func (CacheRedisConfig) Db() int64 { return 0 } -func (CacheRedisConfig) Password() string { +func (cacheredisConfig) Password() string { if v := os.Getenv("CONFIG_CACHE_REDIS_PASSWORD"); v != "" { return v } return "" } -func (CacheConfig) Ttl() time.Duration { +func (cacheConfig) Ttl() time.Duration { if v := os.Getenv("CONFIG_CACHE_TTL"); v != "" { if d, err := time.ParseDuration(v); err == nil { return d @@ -161,7 +161,7 @@ func (CacheConfig) Ttl() time.Duration { return 1 * time.Hour } -func (DatabaseConfig) ConnMaxLifetime() time.Duration { +func (databaseConfig) ConnMaxLifetime() time.Duration { if v := os.Getenv("CONFIG_DATABASE_CONN_MAX_LIFETIME"); v != "" { if d, err := time.ParseDuration(v); err == nil { return d @@ -170,14 +170,14 @@ func (DatabaseConfig) ConnMaxLifetime() time.Duration { return 5 * time.Minute } -func (DatabaseConfig) Dsn() string { +func (databaseConfig) Dsn() string { if v := os.Getenv("CONFIG_DATABASE_DSN"); v != "" { return v } return "postgres://localhost/myapp" } -func (DatabaseConfig) MaxIdleConns() int64 { +func (databaseConfig) MaxIdleConns() int64 { if v := os.Getenv("CONFIG_DATABASE_MAX_IDLE_CONNS"); v != "" { if i, err := strconv.ParseInt(v, 10, 64); err == nil { return i @@ -186,7 +186,7 @@ func (DatabaseConfig) MaxIdleConns() int64 { return 5 } -func (DatabaseConfig) MaxOpenConns() int64 { +func (databaseConfig) MaxOpenConns() int64 { if v := os.Getenv("CONFIG_DATABASE_MAX_OPEN_CONNS"); v != "" { if i, err := strconv.ParseInt(v, 10, 64); err == nil { return i @@ -195,11 +195,11 @@ func (DatabaseConfig) MaxOpenConns() int64 { return 25 } -func (DatabaseConfig) Pool() DatabasePoolConfig { - return DatabasePoolConfig{} +func (databaseConfig) Pool() databasepoolConfig { + return databasepoolConfig{} } -func (DatabasePoolConfig) Enabled() bool { +func (databasepoolConfig) Enabled() bool { if v := os.Getenv("CONFIG_DATABASE_POOL_ENABLED"); v != "" { if b, err := strconv.ParseBool(v); err == nil { return b @@ -208,7 +208,7 @@ func (DatabasePoolConfig) Enabled() bool { return true } -func (DatabasePoolConfig) MaxSize() int64 { +func (databasepoolConfig) MaxSize() int64 { if v := os.Getenv("CONFIG_DATABASE_POOL_MAX_SIZE"); v != "" { if i, err := strconv.ParseInt(v, 10, 64); err == nil { return i @@ -217,7 +217,7 @@ func (DatabasePoolConfig) MaxSize() int64 { return 10 } -func (DatabasePoolConfig) MinSize() int64 { +func (databasepoolConfig) MinSize() int64 { if v := os.Getenv("CONFIG_DATABASE_POOL_MIN_SIZE"); v != "" { if i, err := strconv.ParseInt(v, 10, 64); err == nil { return i @@ -226,21 +226,21 @@ func (DatabasePoolConfig) MinSize() int64 { return 2 } -func (EndpointsItem) Methods() []string { +func (endpointsItem) Methods() []string { if v := os.Getenv("CONFIG_ENDPOINTS_METHODS"); v != "" { // Array overrides not supported via env vars } return []string{"GET", "POST"} } -func (EndpointsItem) Path() string { +func (endpointsItem) Path() string { if v := os.Getenv("CONFIG_ENDPOINTS_PATH"); v != "" { return v } return "/api/v1" } -func (EndpointsItem) RateLimit() int64 { +func (endpointsItem) RateLimit() int64 { if v := os.Getenv("CONFIG_ENDPOINTS_RATE_LIMIT"); v != "" { if i, err := strconv.ParseInt(v, 10, 64); err == nil { return i @@ -249,7 +249,7 @@ func (EndpointsItem) RateLimit() int64 { return 100 } -func (FeaturesItem) Enabled() bool { +func (featuresItem) Enabled() bool { if v := os.Getenv("CONFIG_FEATURES_ENABLED"); v != "" { if b, err := strconv.ParseBool(v); err == nil { return b @@ -258,14 +258,14 @@ func (FeaturesItem) Enabled() bool { return true } -func (FeaturesItem) Name() string { +func (featuresItem) Name() string { if v := os.Getenv("CONFIG_FEATURES_NAME"); v != "" { return v } return "authentication" } -func (FeaturesItem) Priority() int64 { +func (featuresItem) Priority() int64 { if v := os.Getenv("CONFIG_FEATURES_PRIORITY"); v != "" { if i, err := strconv.ParseInt(v, 10, 64); err == nil { return i @@ -274,14 +274,14 @@ func (FeaturesItem) Priority() int64 { return 1 } -func (ServerConfig) Addr() string { +func (serverConfig) Addr() string { if v := os.Getenv("CONFIG_SERVER_ADDR"); v != "" { return v } return ":8080" } -func (ServerConfig) Cert() []byte { +func (serverConfig) Cert() []byte { // Check for file path to load if path := os.Getenv("CONFIG_SERVER_CERT"); path != "" { if data, err := os.ReadFile(path); err == nil { @@ -329,7 +329,7 @@ func (ServerConfig) Cert() []byte { } } -func (ServerConfig) Debug() bool { +func (serverConfig) Debug() bool { if v := os.Getenv("CONFIG_SERVER_DEBUG"); v != "" { if b, err := strconv.ParseBool(v); err == nil { return b @@ -338,7 +338,7 @@ func (ServerConfig) Debug() bool { return true } -func (ServerConfig) IdleTimeout() time.Duration { +func (serverConfig) IdleTimeout() time.Duration { if v := os.Getenv("CONFIG_SERVER_IDLE_TIMEOUT"); v != "" { if d, err := time.ParseDuration(v); err == nil { return d @@ -347,7 +347,7 @@ func (ServerConfig) IdleTimeout() time.Duration { return 5 * time.Minute } -func (ServerConfig) MaxHeaderBytes() int64 { +func (serverConfig) MaxHeaderBytes() int64 { if v := os.Getenv("CONFIG_SERVER_MAX_HEADER_BYTES"); v != "" { if i, err := strconv.ParseInt(v, 10, 64); err == nil { return i @@ -356,7 +356,7 @@ func (ServerConfig) MaxHeaderBytes() int64 { return 1048576 } -func (ServerConfig) ReadTimeout() time.Duration { +func (serverConfig) ReadTimeout() time.Duration { if v := os.Getenv("CONFIG_SERVER_READ_TIMEOUT"); v != "" { if d, err := time.ParseDuration(v); err == nil { return d @@ -365,7 +365,7 @@ func (ServerConfig) ReadTimeout() time.Duration { return 15 * time.Second } -func (ServerConfig) ShutdownTimeout() time.Duration { +func (serverConfig) ShutdownTimeout() time.Duration { if v := os.Getenv("CONFIG_SERVER_SHUTDOWN_TIMEOUT"); v != "" { if d, err := time.ParseDuration(v); err == nil { return d @@ -374,7 +374,7 @@ func (ServerConfig) ShutdownTimeout() time.Duration { return 2*time.Hour + 30*time.Minute } -func (ServerConfig) Timeout() time.Duration { +func (serverConfig) Timeout() time.Duration { if v := os.Getenv("CONFIG_SERVER_TIMEOUT"); v != "" { if d, err := time.ParseDuration(v); err == nil { return d @@ -383,7 +383,7 @@ func (ServerConfig) Timeout() time.Duration { return 30 * time.Second } -func (ServerConfig) WriteTimeout() time.Duration { +func (serverConfig) WriteTimeout() time.Duration { if v := os.Getenv("CONFIG_SERVER_WRITE_TIMEOUT"); v != "" { if d, err := time.ParseDuration(v); err == nil { return d @@ -392,35 +392,35 @@ func (ServerConfig) WriteTimeout() time.Duration { return 15 * time.Second } -func (ServiceConfig) AllowedOrigins() []string { +func (serviceConfig) AllowedOrigins() []string { if v := os.Getenv("CONFIG_SERVICE_ALLOWED_ORIGINS"); v != "" { // Array overrides not supported via env vars } return []string{"https://example.com", "https://app.example.com"} } -func (ServiceConfig) Features() []string { +func (serviceConfig) Features() []string { if v := os.Getenv("CONFIG_SERVICE_FEATURES"); v != "" { // Array overrides not supported via env vars } return []string{"auth", "cache", "metrics"} } -func (ServiceConfig) Name() string { +func (serviceConfig) Name() string { if v := os.Getenv("CONFIG_SERVICE_NAME"); v != "" { return v } return "api" } -func (ServiceConfig) Ports() []int64 { +func (serviceConfig) Ports() []int64 { if v := os.Getenv("CONFIG_SERVICE_PORTS"); v != "" { // Array overrides not supported via env vars } return []int64{8080, 8081, 8082} } -func (ServiceConfig) Weights() []float64 { +func (serviceConfig) Weights() []float64 { if v := os.Getenv("CONFIG_SERVICE_WEIGHTS"); v != "" { // Array overrides not supported via env vars } @@ -428,12 +428,12 @@ func (ServiceConfig) Weights() []float64 { } var ( - App AppConfig - Cache CacheConfig - Database DatabaseConfig - Endpoints []EndpointsItem - Features []FeaturesItem + App appConfig + Cache cacheConfig + Database databaseConfig + Endpoints []endpointsItem + Features []featuresItem Name string - Server ServerConfig - Service ServiceConfig + Server serverConfig + Service serviceConfig ) diff --git a/internal/generator/generator_test.go b/internal/generator/generator_test.go index 6404bb5..577e11b 100644 --- a/internal/generator/generator_test.go +++ b/internal/generator/generator_test.go @@ -164,15 +164,15 @@ max_conns = 25 require.Contains(t, outputStr, `"time"`, "output missing time import") // Check empty structs - require.Contains(t, outputStr, "type ServerConfig struct{}", "output missing empty ServerConfig struct") - require.Contains(t, outputStr, "type DatabaseConfig struct{}", "output missing empty DatabaseConfig struct") + require.Contains(t, outputStr, "type serverConfig struct{}", "output missing empty serverConfig struct") + require.Contains(t, outputStr, "type databaseConfig struct{}", "output missing empty databaseConfig struct") // Check getter methods exist - require.Contains(t, outputStr, "func (ServerConfig) Addr() string", "output missing Addr getter") - require.Contains(t, outputStr, "func (ServerConfig) Timeout() time.Duration", "output missing Timeout getter") - require.Contains(t, outputStr, "func (ServerConfig) Port() int64", "output missing Port getter") - require.Contains(t, outputStr, "func (ServerConfig) Debug() bool", "output missing Debug getter") - require.Contains(t, outputStr, "func (DatabaseConfig) MaxConns() int64", "output missing MaxConns getter") + require.Contains(t, outputStr, "func (serverConfig) Addr() string", "output missing Addr getter") + require.Contains(t, outputStr, "func (serverConfig) Timeout() time.Duration", "output missing Timeout getter") + require.Contains(t, outputStr, "func (serverConfig) Port() int64", "output missing Port getter") + require.Contains(t, outputStr, "func (serverConfig) Debug() bool", "output missing Debug getter") + require.Contains(t, outputStr, "func (databaseConfig) MaxConns() int64", "output missing MaxConns getter") // Check env var logic require.Contains(t, outputStr, `os.Getenv("CONFIG_SERVER_ADDR")`, "output missing env var check for addr") @@ -193,9 +193,9 @@ max_conns = 25 // Check var declarations (allow for variable spacing due to gofmt alignment) require.Contains(t, outputStr, "Server", "output missing Server var") - require.Contains(t, outputStr, "ServerConfig", "output missing ServerConfig type") + require.Contains(t, outputStr, "serverConfig", "output missing serverConfig type") require.Contains(t, outputStr, "Database", "output missing Database var") - require.Contains(t, outputStr, "DatabaseConfig", "output missing DatabaseConfig type") + require.Contains(t, outputStr, "databaseConfig", "output missing databaseConfig type") } func TestGenerator_GetterMode_NestedStructs(t *testing.T) { @@ -215,18 +215,18 @@ min_size = 2 outputStr := string(output) // Check nested structs - require.Contains(t, outputStr, "type DatabaseConfig struct{}", "output missing DatabaseConfig") - require.Contains(t, outputStr, "type DatabasePoolConfig struct{}", "output missing DatabasePoolConfig") + require.Contains(t, outputStr, "type databaseConfig struct{}", "output missing databaseConfig") + require.Contains(t, outputStr, "type databasepoolConfig struct{}", "output missing databasepoolConfig") // Check nested getter returns nested struct - require.Contains(t, outputStr, "func (DatabaseConfig) Pool() DatabasePoolConfig", "output missing Pool getter") - require.Contains(t, outputStr, "return DatabasePoolConfig{}", "output missing DatabasePoolConfig return") + require.Contains(t, outputStr, "func (databaseConfig) Pool() databasepoolConfig", "output missing Pool getter") + require.Contains(t, outputStr, "return databasepoolConfig{}", "output missing databasepoolConfig return") // Check nested struct methods with correct env var names require.Contains(t, outputStr, `os.Getenv("CONFIG_DATABASE_POOL_MAX_SIZE")`, "output missing nested env var") require.Contains(t, outputStr, `os.Getenv("CONFIG_DATABASE_POOL_MIN_SIZE")`, "output missing nested env var") - require.Contains(t, outputStr, "func (DatabasePoolConfig) MaxSize() int64", "output missing nested MaxSize getter") - require.Contains(t, outputStr, "func (DatabasePoolConfig) MinSize() int64", "output missing nested MinSize getter") + require.Contains(t, outputStr, "func (databasepoolConfig) MaxSize() int64", "output missing nested MaxSize getter") + require.Contains(t, outputStr, "func (databasepoolConfig) MinSize() int64", "output missing nested MinSize getter") } func TestGenerator_GetterMode_Arrays(t *testing.T) { @@ -243,8 +243,8 @@ ports = [8080, 8081] outputStr := string(output) // Check array getters with limitation comment - require.Contains(t, outputStr, "func (ServiceConfig) Hosts() []string", "output missing Hosts getter") - require.Contains(t, outputStr, "func (ServiceConfig) Ports() []int64", "output missing Ports getter") + require.Contains(t, outputStr, "func (serviceConfig) Hosts() []string", "output missing Hosts getter") + require.Contains(t, outputStr, "func (serviceConfig) Ports() []int64", "output missing Ports getter") require.Contains(t, outputStr, "// Array overrides not supported via env vars", "output missing array limitation comment") require.Contains(t, outputStr, `return []string{"localhost", "example.com"}`, "output missing hosts default") require.Contains(t, outputStr, "return []int64{8080, 8081}", "output missing ports default") @@ -267,10 +267,10 @@ db = 0 outputStr := string(output) // Check that Redis methods are only generated once - addrCount := strings.Count(outputStr, "func (CacheRedisConfig) Addr() string") + addrCount := strings.Count(outputStr, "func (cacheredisConfig) Addr() string") require.Equal(t, 1, addrCount, "Addr method should be generated exactly once") - dbCount := strings.Count(outputStr, "func (CacheRedisConfig) Db() int64") + dbCount := strings.Count(outputStr, "func (cacheredisConfig) Db() int64") require.Equal(t, 1, dbCount, "Db method should be generated exactly once") } @@ -332,7 +332,7 @@ tls_key = "file:files/small.txt" outputStr := string(output) // Check file loading logic exists - require.Contains(t, outputStr, "func (ServerConfig) TlsCert() []byte", "output missing TlsCert getter") + require.Contains(t, outputStr, "func (serverConfig) TlsCert() []byte", "output missing TlsCert getter") require.Contains(t, outputStr, `os.Getenv("CONFIG_SERVER_TLS_CERT")`, "output missing file path env var check") require.Contains(t, outputStr, "os.ReadFile(path)", "output missing file read") require.Contains(t, outputStr, "return data", "output missing return data") @@ -341,6 +341,6 @@ tls_key = "file:files/small.txt" require.Contains(t, outputStr, "return []byte{", "output missing embedded fallback bytes") // Check same for key - require.Contains(t, outputStr, "func (ServerConfig) TlsKey() []byte", "output missing TlsKey getter") + require.Contains(t, outputStr, "func (serverConfig) TlsKey() []byte", "output missing TlsKey getter") require.Contains(t, outputStr, `os.Getenv("CONFIG_SERVER_TLS_KEY")`, "output missing file path env var check for key") } diff --git a/internal/generator/struct_gen.go b/internal/generator/struct_gen.go index cd24195..f2e9610 100644 --- a/internal/generator/struct_gen.go +++ b/internal/generator/struct_gen.go @@ -382,11 +382,11 @@ func (g *Generator) generateStructsAndGetters(buf *bytes.Buffer, data map[string allStructs := make(map[string]map[string]any) for _, key := range keys { if m, ok := data[key].(map[string]any); ok { - structName := sx.PascalCase(key) + "Config" + structName := sx.CamelCase(key) + "Config" g.collectNestedStructsForGetters(allStructs, structName, m) } else if arr, ok := data[key].([]map[string]any); ok { if len(arr) > 0 { - structName := sx.PascalCase(key) + "Item" + structName := sx.CamelCase(key) + "Item" g.collectNestedStructsForGetters(allStructs, structName, arr[0]) } } @@ -420,10 +420,10 @@ func (g *Generator) generateStructsAndGetters(buf *bytes.Buffer, data map[string switch value.(type) { case map[string]any: - structName := sx.PascalCase(key) + "Config" + structName := sx.CamelCase(key) + "Config" fmt.Fprintf(buf, "\t%s %s\n", varName, structName) case []map[string]any: - structName := sx.PascalCase(key) + "Item" + structName := sx.CamelCase(key) + "Item" fmt.Fprintf(buf, "\t%s []%s\n", varName, structName) case []any: goType := g.toGoType(value) @@ -449,18 +449,18 @@ func (g *Generator) collectNestedStructsForGetters(structs map[string]map[string for key, val := range data { switch v := val.(type) { case map[string]any: - nestedName := stripSuffix(name) + sx.PascalCase(key) + "Config" + nestedName := stripSuffix(name) + sx.CamelCase(key) + "Config" g.collectNestedStructsForGetters(structs, nestedName, v) case []any: if len(v) > 0 { if m, ok := v[0].(map[string]any); ok { - nestedName := stripSuffix(name) + sx.PascalCase(key) + "Item" + nestedName := stripSuffix(name) + sx.CamelCase(key) + "Item" g.collectNestedStructsForGetters(structs, nestedName, m) } } case []map[string]any: if len(v) > 0 { - nestedName := stripSuffix(name) + sx.PascalCase(key) + "Item" + nestedName := stripSuffix(name) + sx.CamelCase(key) + "Item" g.collectNestedStructsForGetters(structs, nestedName, v[0]) } } @@ -495,7 +495,7 @@ func (g *Generator) generateGetterMethods(buf *bytes.Buffer, structName string, // Handle nested structs - they need their own getter methods if nestedMap, ok := value.(map[string]any); ok { - nestedStructName := stripSuffix(structName) + sx.PascalCase(fieldName) + "Config" + nestedStructName := stripSuffix(structName) + sx.CamelCase(fieldName) + "Config" // Generate method that returns nested struct fmt.Fprintf(buf, "func (%s) %s() %s {\n", structName, goFieldName, nestedStructName) fmt.Fprintf(buf, "\treturn %s{}\n", nestedStructName) @@ -510,7 +510,7 @@ func (g *Generator) generateGetterMethods(buf *bytes.Buffer, structName string, // Handle arrays of structs - for now, return empty slice (limitation) if arr, ok := value.([]any); ok && len(arr) > 0 { if _, isMap := arr[0].(map[string]any); isMap { - nestedStructName := stripSuffix(structName) + sx.PascalCase(fieldName) + "Item" + nestedStructName := stripSuffix(structName) + sx.CamelCase(fieldName) + "Item" goType := "[]" + nestedStructName // For arrays of structs, return default empty value fmt.Fprintf(buf, "func (%s) %s() %s {\n", structName, goFieldName, goType) @@ -522,7 +522,7 @@ func (g *Generator) generateGetterMethods(buf *bytes.Buffer, structName string, } if arr, ok := value.([]map[string]any); ok && len(arr) > 0 { - nestedStructName := stripSuffix(structName) + sx.PascalCase(fieldName) + "Item" + nestedStructName := stripSuffix(structName) + sx.CamelCase(fieldName) + "Item" goType := "[]" + nestedStructName fmt.Fprintf(buf, "func (%s) %s() %s {\n", structName, goFieldName, goType) fmt.Fprintf(buf, "\t// Arrays of structs cannot be overridden via env vars\n")