本文整理汇总了Golang中github.com/janelia-flyem/dvid/dvid.Config.GetBool方法的典型用法代码示例。如果您正苦于以下问题:Golang Config.GetBool方法的具体用法?Golang Config.GetBool怎么用?Golang Config.GetBool使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/janelia-flyem/dvid/dvid.Config
的用法示例。
在下文中一共展示了Config.GetBool方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: NewDataService
// NewData returns a pointer to new tile data with default values.
func (dtype *Type) NewDataService(uuid dvid.UUID, id dvid.InstanceID, name dvid.InstanceName, c dvid.Config) (datastore.DataService, error) {
// Make sure we have a valid DataService source
sourcename, found, err := c.GetString("Source")
if err != nil {
return nil, err
}
if !found {
return nil, fmt.Errorf("Cannot make imagetile data without valid 'Source' setting.")
}
// See if we want placeholder imagetile.
placeholder, found, err := c.GetBool("Placeholder")
if err != nil {
return nil, err
}
// Determine encoding for tile storage and this dictates what kind of compression we use.
encoding, found, err := c.GetString("Format")
if err != nil {
return nil, err
}
format := PNG
if found {
switch strings.ToLower(encoding) {
case "lz4":
format = LZ4
case "png":
format = PNG
case "jpg":
format = JPG
default:
return nil, fmt.Errorf("Unknown encoding specified: '%s' (should be 'lz4', 'png', or 'jpg'", encoding)
}
}
// Compression is determined by encoding. Inform user if there's a discrepancy.
var compression string
switch format {
case LZ4:
compression = "lz4"
case PNG:
compression = "none"
case JPG:
compression = "none"
}
compressConfig, found, err := c.GetString("Compression")
if err != nil {
return nil, err
}
if found && strings.ToLower(compressConfig) != compression {
return nil, fmt.Errorf("Conflict between specified compression '%s' and format '%s'. Suggest not dictating compression.",
compressConfig, encoding)
}
c.Set("Compression", compression)
// Initialize the imagetile data
basedata, err := datastore.NewDataService(dtype, uuid, id, name, c)
if err != nil {
return nil, err
}
data := &Data{
Data: basedata,
Properties: Properties{
Source: dvid.InstanceName(sourcename),
Placeholder: placeholder,
Encoding: format,
},
}
return data, nil
}