diff options
author | 2023-07-07 16:17:39 +0200 | |
---|---|---|
committer | 2023-07-07 16:17:39 +0200 | |
commit | 2a99df0588e168660d3b528209d8f51689ca92b7 (patch) | |
tree | a5835c3a0adf81ad4f07938919699fbc0de4a69b /internal/config/gen/gen.go | |
parent | [bugfix] Reorder web view logic, other small fixes (#1954) (diff) | |
download | gotosocial-2a99df0588e168660d3b528209d8f51689ca92b7.tar.xz |
[feature] enable + document explicit IP dialer allowing/denying (#1950)v0.10.0-rc1
* [feature] enable + document explicit IP dialer allowing/denying
* lord have mercy
* allee jonge
* shortcut check ipv6 prefixes
* comment
* separate httpclient_test, export Sanitizer
Diffstat (limited to 'internal/config/gen/gen.go')
-rw-r--r-- | internal/config/gen/gen.go | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/internal/config/gen/gen.go b/internal/config/gen/gen.go index 30994c652..1c2c11747 100644 --- a/internal/config/gen/gen.go +++ b/internal/config/gen/gen.go @@ -96,16 +96,22 @@ func generateFields(output io.Writer, prefixes []string, t reflect.Type) { flagPath := strings.Join(append(prefixes, field.Tag.Get("name")), "-") flagPath = strings.ToLower(flagPath) + // Get type without "config." prefix. + fieldType := strings.ReplaceAll( + field.Type.String(), + "config.", "", + ) + // ConfigState structure helper methods fmt.Fprintf(output, "// Get%s safely fetches the Configuration value for state's '%s' field\n", name, fieldPath) - fmt.Fprintf(output, "func (st *ConfigState) Get%s() (v %s) {\n", name, field.Type.String()) + fmt.Fprintf(output, "func (st *ConfigState) Get%s() (v %s) {\n", name, fieldType) fmt.Fprintf(output, "\tst.mutex.Lock()\n") fmt.Fprintf(output, "\tv = st.config.%s\n", fieldPath) fmt.Fprintf(output, "\tst.mutex.Unlock()\n") fmt.Fprintf(output, "\treturn\n") fmt.Fprintf(output, "}\n\n") fmt.Fprintf(output, "// Set%s safely sets the Configuration value for state's '%s' field\n", name, fieldPath) - fmt.Fprintf(output, "func (st *ConfigState) Set%s(v %s) {\n", name, field.Type.String()) + fmt.Fprintf(output, "func (st *ConfigState) Set%s(v %s) {\n", name, fieldType) fmt.Fprintf(output, "\tst.mutex.Lock()\n") fmt.Fprintf(output, "\tdefer st.mutex.Unlock()\n") fmt.Fprintf(output, "\tst.config.%s = v\n", fieldPath) @@ -117,8 +123,8 @@ func generateFields(output io.Writer, prefixes []string, t reflect.Type) { fmt.Fprintf(output, "// %sFlag returns the flag name for the '%s' field\n", name, fieldPath) fmt.Fprintf(output, "func %sFlag() string { return \"%s\" }\n\n", name, flagPath) fmt.Fprintf(output, "// Get%s safely fetches the value for global configuration '%s' field\n", name, fieldPath) - fmt.Fprintf(output, "func Get%[1]s() %[2]s { return global.Get%[1]s() }\n\n", name, field.Type.String()) + fmt.Fprintf(output, "func Get%[1]s() %[2]s { return global.Get%[1]s() }\n\n", name, fieldType) fmt.Fprintf(output, "// Set%s safely sets the value for global configuration '%s' field\n", name, fieldPath) - fmt.Fprintf(output, "func Set%[1]s(v %[2]s) { global.Set%[1]s(v) }\n\n", name, field.Type.String()) + fmt.Fprintf(output, "func Set%[1]s(v %[2]s) { global.Set%[1]s(v) }\n\n", name, fieldType) } } |