-
Notifications
You must be signed in to change notification settings - Fork 3
/
config.go
50 lines (44 loc) · 1.01 KB
/
config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package lore
/*
_config holds the current Config instance. Note that this should NEVER be accessed directly, and
should instead be retrieved via GetConfig to provide null safety.
*/
var _config *Config
/*
Config provides a struct for configuring all LORE queries.
*/
type Config struct {
/*
DB driver's placeholder format for injecting query parameters via SQL.
*/
SQLPlaceholderFormat SQLPlaceholderFormat
}
/*
GetConfig returns the current config object. If no config already exists, a default is given.
*/
func GetConfig() *Config {
if _config == nil {
_config = GetConfigDefault()
}
return _config
}
/*
GetConfigDefault returns the default config object.
*/
func GetConfigDefault() *Config {
return &Config{
SQLPlaceholderFormat: SQLPlaceholderFormatDollar,
}
}
/*
SetConfig sets the current config for all future LORE queries.
*/
func SetConfig(c *Config) {
_config = c
}
/*
SetConfigDefault sets a default config for all future LORE queries.
*/
func SetConfigDefault() {
SetConfig(GetConfigDefault())
}