Help us shape the future of Go! Take the 2026 Go Developer Survey

goption

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 23, 2013 License: MIT Imports: 2 Imported by: 1

README

goption

Build Status

Option container for golang

Installation

go get github.com/ddliu/goption

Usage

import "github.com/ddliu/goption"

// create option

o := goption.NewOption(map[string]interface{} {
    "timeout": 100,
    "cacheable": true,
})

o.MergeMap(map[string]interface{} {
    "prefix": "key_",
    "size": 1.5,
})

timeout, ok := o.GetInt("timeout")

cachable := o.MustGetBool("cacheable")

size: = o.MustGetFloat32("size")

xyz, ok := o.GetInt("xyz") // ok is false

xyz := o.MustGetInt("xyz") // panic!

Changelog

v0.1.0 (2013-09-23)

First release

License

Licensed under the MIT license

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option struct {
	// contains filtered or unexported fields
}

func NewOption

func NewOption(data map[string]interface{}) *Option

func (*Option) Get

func (this *Option) Get(key string) (interface{}, bool)

func (*Option) GetBool

func (this *Option) GetBool(key string) (bool, bool)

func (*Option) GetFloat32

func (this *Option) GetFloat32(key string) (float32, bool)

func (*Option) GetFloat64

func (this *Option) GetFloat64(key string) (float64, bool)

func (*Option) GetInt

func (this *Option) GetInt(key string) (int, bool)

func (*Option) GetInt32

func (this *Option) GetInt32(key string) (int32, bool)

func (*Option) GetInt64

func (this *Option) GetInt64(key string) (int64, bool)

func (*Option) GetString

func (this *Option) GetString(key string) (string, bool)

func (*Option) Map

func (this *Option) Map() map[string]interface{}

func (*Option) Merge

func (this *Option) Merge(that *Option)

func (*Option) MergeAs

func (this *Option) MergeAs(that *Option) *Option

func (*Option) MergeMap

func (this *Option) MergeMap(that map[string]interface{})

func (*Option) MergeMapAs

func (this *Option) MergeMapAs(that map[string]interface{}) *Option

func (*Option) MustGet

func (this *Option) MustGet(key string) interface{}

func (*Option) MustGetBool

func (this *Option) MustGetBool(key string) bool

func (*Option) MustGetFloat32

func (this *Option) MustGetFloat32(key string) float32

func (*Option) MustGetFloat64

func (this *Option) MustGetFloat64(key string) float64

func (*Option) MustGetInt

func (this *Option) MustGetInt(key string) int

func (*Option) MustGetInt32

func (this *Option) MustGetInt32(key string) int32

func (*Option) MustGetInt64

func (this *Option) MustGetInt64(key string) int64

func (*Option) MustGetString

func (this *Option) MustGetString(key string) string

func (*Option) Set

func (this *Option) Set(key string, value interface{}) *Option

type OptionError

type OptionError struct {
	// contains filtered or unexported fields
}

func (*OptionError) Error

func (this *OptionError) Error() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL