diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..8e18ca8 --- /dev/null +++ b/Makefile @@ -0,0 +1,2 @@ +fmt: + find . -name '*.go' -exec gofumpt -w -s -extra {} \; \ No newline at end of file diff --git a/lib/convert.go b/lib/convert.go index 7fdd9d2..cdef2ea 100644 --- a/lib/convert.go +++ b/lib/convert.go @@ -39,7 +39,7 @@ func ConvertCommand(c *cli.Context) error { fmt.Println(string(outputData)) } else { outputFile := c.Args().Get(1) - if err := os.WriteFile(outputFile, outputData, 0644); err != nil { + if err := os.WriteFile(outputFile, outputData, 0o644); err != nil { return fmt.Errorf("failed to write output file: %w", err) } } diff --git a/lib/i2pconv.go b/lib/i2pconv.go index 02ad5df..0585a46 100644 --- a/lib/i2pconv.go +++ b/lib/i2pconv.go @@ -46,7 +46,7 @@ func (c *Converter) validate(config *TunnelConfig) error { // Converter handles configuration format conversions type Converter struct { strict bool - //logger Logger + // logger Logger } // Convert transforms between configuration formats diff --git a/lib/ini.go b/lib/ini.go index 1c59f70..d42f5d8 100644 --- a/lib/ini.go +++ b/lib/ini.go @@ -23,7 +23,11 @@ func (c *Converter) parseINI(input []byte) (*TunnelConfig, error) { parts := strings.SplitN(line, "=", 2) if len(parts) != 2 { - continue + if strings.HasPrefix(line, "[") && strings.HasSuffix(line, "]") { + config.Name = strings.TrimSuffix(strings.TrimPrefix(line, "["), "]") + } else { + continue + } } key := strings.TrimSpace(parts[0]) diff --git a/lib/properties.go b/lib/properties.go index 173ee4e..91a47cc 100644 --- a/lib/properties.go +++ b/lib/properties.go @@ -8,7 +8,6 @@ import ( "github.com/magiconair/properties" ) -// Example Java properties parser func (c *Converter) parseJavaProperties(input []byte) (*TunnelConfig, error) { p := properties.MustLoadString(string(input)) @@ -27,7 +26,7 @@ func (c *Converter) parseJavaProperties(input []byte) (*TunnelConfig, error) { return config, nil } -func (c *Converter) parsePropertyKey(k string, s string, config *TunnelConfig) { +func (c *Converter) parsePropertyKey(k, s string, config *TunnelConfig) { if strings.HasPrefix(k, "#") { return } diff --git a/lib/yaml.go b/lib/yaml.go index 37c2412..39bd45f 100644 --- a/lib/yaml.go +++ b/lib/yaml.go @@ -2,7 +2,6 @@ package i2pconv import "gopkg.in/yaml.v2" -// Example YAML parser func (c *Converter) parseYAML(input []byte) (*TunnelConfig, error) { config := &TunnelConfig{} err := yaml.Unmarshal(input, config)