-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5261a37
commit a140302
Showing
4 changed files
with
26 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,26 @@ | ||
package sqlstorage | ||
|
||
import "fmt" | ||
|
||
type Config struct { | ||
// Name of the database | ||
DriverName string `mapstructure:"DriverName"` | ||
DataSource string `mapstructure:"DataSource"` | ||
} | ||
|
||
func (c *Config) String() string { | ||
return fmt.Sprintf("DriverName=%s DataSource=%s", c.DriverName, c.DataSource) | ||
} | ||
|
||
func (c *Config) SanityCheck() error { | ||
if c.DriverName == "" { | ||
return fmt.Errorf("DriverName is required") | ||
} | ||
if c.DataSource == "" { | ||
return fmt.Errorf("DataSource is required") | ||
} | ||
if c.DriverName != SqliteDriverName { | ||
return fmt.Errorf("DriverName not supported: %s, only supports: %s", c.DriverName, SqliteDriverName) | ||
} | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters