mirror of
https://github.com/go-i2p/go-i2ptunnel-config.git
synced 2025-07-12 21:59:33 -04:00
add DetectFormat
This commit is contained in:
@ -130,3 +130,15 @@ func (c *Converter) ParseInput(input []byte, format string) (*TunnelConfig, erro
|
||||
return nil, fmt.Errorf("unsupported input format: %s", format)
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Converter) DetectFormat(path string) (string, error) {
|
||||
ext := strings.ToLower(filepath.Ext(path))
|
||||
if ext == ".properties" || ext == ".prop" || ext == ".config" {
|
||||
return "properties", nil
|
||||
} else if ext == ".yml" || ext == ".yaml" {
|
||||
return "yaml", nil
|
||||
} else if ext == ".ini" {
|
||||
return "ini", nil
|
||||
}
|
||||
return "", fmt.Errorf("unsupported file extension: %s", ext)
|
||||
}
|
||||
|
Reference in New Issue
Block a user