mirror of
https://github.com/cheat/cheat.git
synced 2024-10-31 21:21:02 +01:00
85f5ae8ec7
Make various lint corrections in order to appease `staticcheck`.
24 lines
487 B
Go
24 lines
487 B
Go
package config
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"path/filepath"
|
|
)
|
|
|
|
// Init initializes a config file
|
|
func Init(confpath string, configs string) error {
|
|
|
|
// assert that the config directory exists
|
|
if err := os.MkdirAll(filepath.Dir(confpath), 0755); err != nil {
|
|
return fmt.Errorf("failed to create directory: %v", err)
|
|
}
|
|
|
|
// write the config file
|
|
if err := os.WriteFile(confpath, []byte(configs), 0644); err != nil {
|
|
return fmt.Errorf("failed to create file: %v", err)
|
|
}
|
|
|
|
return nil
|
|
}
|