golang config manager

But there are still so many different ways to do so. @Dr.eel Try separate viper.GetBool("abc") and Viper.Set("abc", false) in different goroutine. Maybe others commit the same error > be warned ;D. I like TOML because it lets me write comments either on newlines or at the end of a line configuring setting. It persists all of your configurations in either $XDG_CONFIG_HOME or $HOME on Linux and in %APPDATA% on Windows. Currently just working for beacon nodes, Package go-unzip provides a very simple library to extract zip archive, A repository of example implementations of using AWS CDK with Go language, Neutrino CloudSync - An open-source tool used to upload entire file folders from any host to any cloud, OpenTelemetry Tracing instrumentation for PostgreSQL, A collactz conjecture service running in kubernets, SSE Client for Flashbots Relayer Data, written in go, Header Block - A middleware plugin for Traefik to block request and response headers which regex matched, A rootless container system written in Go following along Liz Rice's presentation at the goto conference, Lifecycle management of OS2mo entities using the GraphQL API, GSP761 Developing a REST API with Go and Cloud Run, A simulation to show what happens if to switch in Monty Hall problem using Go, Ability to swap out skate.ea graphics with custom ones. I wrote a simple ini config library in golang. Library providing routines to merge and validate JSON, YAML and/or TOML files, Go utility for loading configuration parameters from AWS SSM (Parameter Store). Provide a sub-package dotenv that supports importing data from files (eg .env) to ENV, If you just want to use INI for simple config management, recommended use gookit/ini. // Expand a string containing environment variables in the form of $var or ${var}, "mongodb://${DB_USERNAME}:${DB_PASSWORD}@$DB_HOST:$DB_PORT/$DB_NAME". //Checking that an environment variable is present or not. ===================Update=======================. You can set the default var JSONMarshalIndent or custom a new JSON driver. Never forget to include your environment variable files in the .gitignore. Where developers & technologists share private knowledge with coworkers, Reach developers & technologists worldwide. os.Getenv() will return an empty string if the environment variable is not present, to distinguish between an empty value and an unset value, use LookupEnv. It is commonly used for configuration files and in applications where data is being stored or transmitted. ok is true, find value from config There a couple of reasons: handle config files and environment variables, not command-line parameters; Structure get config data and binding to the dst structure. The // we keep it empty it will load .env from current directory, // getting env variables SITE_TITLE and DB_HOST, // Set the file name of the configurations file, // Set the path to look for the configurations file, // Enable VIPER to read Environment Variables, // viper.Get() returns an empty interface{}, // so we have to do the type assertion, to get the value, // if type assert is not valid it will throw an error, M2M Authorization: Authenticate Apps, APIs, and Web Services, Implement HTTP Streaming with Node.js and Fetch API, NestJS: How to Implement Session-Based User Authentication, How to Integrate Invisible reCAPTCHA for Bot Protection, Latest Golang version installed on your system. If you are managing variables in one place, in case of any changes, you don't have to change it in all the places in application code. Good work. Now with error monitoring and external services monitoring, Scout is a developer's best friend when it comes to application development. pflags is using the posix-standard.

solution for Go. Clean and minimalistic environment configuration reader for Golang, Composable, observable and performant config handling for Go for the distributed processing era, Load configuration in cascade from multiple backends into a struct, Go configuration manage(load,get,set,export). It is based on the git config format. For those reading this and going down that route, beware: JSONs lack of comments makes it unsuitable for a human usable configuration file (imo). Environment variables are easy to change between deploys without changing any application code. LoadFlags parse command line arguments, based on provide keys. I noticed it was the method used by all the configuration options I could find. If you dont want to manage it by yourself, you can use gonfig or viper. Each config update requires update in code what is very annoying.

In my view, the only proper way to do that - add a full list of environment variables into a help output, including descriptions, default values and other meaningful information. - Key is not case-sensitive when getting, Int64 get a int value, if not found return default value, IntMap get config data as a map[string]int, Ints get config data as a int slice/array, LoadExists load one or multi files, will ignore not exist, LoadExistsByFormat load one or multi files by give format, LoadFilesByFormat load one or multi files by give format. So, Im happy if it will help you. Pros and cons for different configuration formats? Why had climate change not been proven beyond doubt for so long?

MapOnExists mapping data to the dst structure only on key exists. This package is not in the latest version of its module. We can load the config file from any path we want. Other drivers are used on demand, not used will not be loaded into the application. Powered by: Hugo, Cloud Architect | Community Leader | Public Speaker, `yml:"port" env:"PORT" env-default:"5432"`, `yml:"host" env:"HOST" env-default:"localhost"`, `yml:"name" env:"NAME" env-default:"postgres"`, `yml:"user" env:"USER" env-default:"user"`, `env:"PORT" env-description:"server port"`, `env:"HOST" env-description:"server host"`, `env:"PORT" env-description:"server port" env-default:"5432"`, `env:"HOST" env-description:"server host" env-default:"localhost"`, `env:"NAME" env-description:"server name" env-default:"postgres"`, `env:"USER" env-description:"server username" env-default:"user"`, `env:"PASSWORD" env-description:"server password"`.

we can load multiple env files at once also. For example, you may want to get configuration from a remote server, or some other tool, or update them. 465), Design patterns for asynchronous API communication. When a project reaches major version v1 it is considered stable. is not the case with many ini-type config parsers. Quick and easy way to load config files based on a simple set of rules. like os.Getenv, but support default value First, it will read the file, and then try to find environment variables using names in env tags.

There are many good approaches to handle configuration in a modern application. And thats why a structured format was chosen as a base for configuration. Go helpers to manage environment variables, Library for setting values to structs' fields from env, flags, files or default tag, A cross platform package that follows the XDG Standard, Configure is a Go package that gives you easy configuration of your project through redundancy, Lightweight, zero-dependency, and extendable configuration management library for Go, go implementation of lightbend's HOCON configuration library https://github.com/lightbend/config. Iniflags elegantly solves this problem: just modify two lines in your main package and it magically gains support for reading flag values from ini file. Normally, the app uses either a command-line approach (CLI tools) or config file + environment approach (web services, containerized apps, etc.). Your configuration should probably be loaded at the beginning of your program, and the values then passed to your dependencies.

Using environment variables is an excellent way to handle configuration in our application. would suggest to use pflags instead of flags. Usage: LoadStrings load data from source string content. I mean, can a newer version of the config file be used with older version of code? There is no common answer. of following(case insensitive): The `ok` boolean will be false in the event that the value could not be parsed as a bool, DumpTo use the format(json,yaml,toml) dump config data to a writer. Go. In the below code, we are using Viper to load environment variables from a config.yaml. These are often used to make the same program behave differently in different deployment environments like PROD, DEV, or TEST. Another option is to use TOML, which is an INI-like format created by Tom Preston-Werner. Everything goes clean and visible. Look, when I say its dead simple, I actually mean it: Store supports any other formats via the handy registration system: register the format once and youd be able to Load and Save files in it afterwards: John was the first writer to have joined golangexample.com. like: "${EnvName}" "${EnvName|default}", // parse key, allow find value by key path. It's simple - if you want something simple, this is a good choice. Want to improve this question? You define your config items in your application as a struct.

For example, this is an api client, and I'd like to use flags, but it seems like it would over complicate my testing (, would be very helpful if there were detailed example code here showing a working example :). But both approaches have the same issue - a lot of magic inside. There is something I really dont like - environment variables because they are the same bad as global variables. Story: man purchases plantation on planet, finds 'unstoppable' infestation, uses science, electrolyses water for oxygen, 1970s-1980s. I dont use global variables, I structure my code the readable way and may my code flow certain and clear.

It enables applications to be portable. Every approach to config does. Bool looks up a value for a key in this section and attempts to parse that value as a boolean, We can also set the default values for any environment variable if any environment variable is not available in the config file. and send the filename and the struct to gonfig : So now we are able to manage conf like if we had only one config source. Kotlin SpringBoot App in Minikube Windows Cluster, How to deploy a Go application with Postgres on Patr, gRPC Interceptor: unary interceptor with code exampleTechdozo, //filename is the path to the json config file, configuration.Connection_String = os.Getenv("Connection_String"), Best practices for Configuration file in your code. I'm new at Go programming, and I'm wondering: what is the preferred way to handle configuration parameters for a Go program (the kind of stuff one might use properties files or ini files for, in other contexts)?

Loading configuration in separate goroutines is probably the wrong way to do it. Keep you config structs along the code they configure and delegate parsing to submodules without sacrificing full config serialization. Uint get a int value, if not found return default value. On your code you will need to declare your variables. A json config file template from your struct is saved on the first run, You can save runtime modifications to the config, Does have a little convention built-in, which I now if frowned upon in general in Go community. How else would your program be aware of the new config?

go-up! The main idea behind the cleanenv library is to make everything explicit and clean. I built a Go parser for it that is extensively tested. There are two more functions os.Clearenv and os.Environ() let's use them also in a separate program. How did this note help previous owner of this old film camera? And will access them in a Go application using inbuilt and third-party packages. Can use empty string for bind all config data to a struct: config.MapOnExists like BindStructbut map binding only if key exists, Support simple flags parameter parsing, loading, Now, you can add a hook func for listen config data change.

And I like that. YAML supports comments, if you want to add notes everywhere in config file. A simple and zero-dependencies library to parse environment variables into structs. Someone (it may be you, another developer, DevOps, or just someone forced to do that) needs to find a list of environment variables used, and then use them properly. LoginRadius empowers businesses to deliver a delightful customer experience and win customer trust. I made a new simple config file format, and a more dynamic-ish lib for reading it out. It also supports slice values, so you can allow specifying a key multiple times and other nice features like that. weekly report. Int get a int value, if not found return default value. How can I save application settings in a Windows Forms application? Pass environment variables from docker to my GoLang. An opinionated configuration loading framework for Containerized and Cloud-Native applications. It also allows environment variables to be loaded from the .env file. I have started using Gcfg which uses Ini-like files. readable. Each approach has its own best practices. Viper is a complete configuration solution for Go applications including twelve-factor apps. Once we run os.Clearenv() it will clear all the environment variables for the running process. But you can handle them the right way too if you will read them once at the beginning. It worked. WriteTo Write out config data representing the current state to a writer. Possibility to add custom driver for your specific format, Support multi-file and multi-data loading, Support loading configuration from os ENV, Support for loading configuration data from remote URLs, Support for setting configuration data from command line arguments(. But even if the structure contains the explicit mapping of each environment variable, it is still hard to set up the environment outside the app. Package toml is driver use TOML format content as config source Usage please see example: Package yaml is a driver use YAML format content as config source Usage please see example: Package yamlv3 is a driver use YAML format content as config source Usage please see example: // JSONAllowComments support write comments on json file. Create a main.go file in an empty folder. I agree with nemo and I wrote a little tool to make it all real easy. no magic, explicit way to read and use configuration; I havent found anything not overcomplicated but still useful, with explicit configuration setup and clean and informative help output, so Ive built it on my own. easy integration with other libraries. A configuration library for Go that parses environment variables, JSON files, and reloads automatically on SIGHUP. Support listen and fire events on config data changed. Instantiate/configure structs recursively, based on build environment. Package ini provides INI file read and write functionality in Go. Connect and share knowledge within a single location that is structured and easy to search. Provides CMDLine Args and Env args, Go module to build a decisional tree from a json, Gojest is like jest(nodejs) in golang, Press the `F` key to focus on your first error, Compares recent (07.2022) GPUs in performance and price (German market), A CLI tool to check the status of URLs on webpages, Reverse proxy to ethereum nodes. It looks pretty interesting. I can't do that with JSON. No global state, no encapsulated maps, no magical background updates nether any other hidden work. Simple task, huh? while offering semantics for lists and mappings (which can become quite handy), which The community reviewed whether to reopen this question 5 months ago and left it closed: Opinion-based Update the question so it can be answered with facts and citations by editing this post. Golang package for use comments in JSON config files, Clean code begins in your IDE with SonarLint, SaaSHub - Software Alternatives and Reviews. Okay, they can be listed in the documentation or in the source code. Do not use Viper, it's not thread-safe which almost fired me. How to avoid annoying error "declared and not used", Pointers vs. values in parameters and return values, Function declaration syntax: things in parenthesis before function name. It's actually pretty close to the nginx configuration file format, if you're already familiar with that.

Awesome Go List and direct contributions here. Why? ok is false, not found or error, Getenv get os ENV value by name. Ahhh - I tried that in my code and forgot to define the struct attributes with uppercase letters (not exported) - this cost me an hour of my life. To fix that the cleanenv library contains the possibility to add a well-structured list of environment variables with descriptions into help output: It will help you to get the documentation synchronized with your app with no need to have extra files. So the cleanenv library is not the key for every lock.

Build-environment aware toolbox factory and agnostic config parser (YAML, TOML, JSON and Environment vars). Decoder for decode yml,json,toml format content, Driver interface. Then in the main.go file we will use godotenv to load the environment variables. Notice: The above function will list all the environment variables available in the system, including NAME and DB_HOST.

After that, when calling LoadXXX, Set, SetData, ClearData etc methods, it will output: Can use config.DumpTo() export the configuration data to the specified writer, such as: buffer,file. It is definitely not a tool-for-everything. Harvest configuration, watch and notify subscriber, Go package that interfaces with AWS System Manager, A golang package for parsing ini-style configuration files, Un-marshaling environment variables to Go structs. The downside is that you easily end up with a bunch of code to tell the user where the error was, various edge cases and what not. Our goal is to help you find the software and libraries you need. If there were no data found in file neither in the environment, the constant from the env-default will be used instead. This one is good, since I don't have to redefine entire config structure in go, How to handle configuration in Go [closed], Persisting Application Configuration In Go, https://groups.google.com/forum/#!topic/golang-nuts/TByzyPgoAQE, Learn more about Collectives on Stack Overflow, How APIs can take the pain out of legacy system headaches (Ep. Source code and other details for the project are available at GitHub: Usage please see example(more example please see examples folder in the lib): there are some event names for config data changed. "Selected/commanded," "indicated," what's the third word?

I tried JSON. A simple configuration library with recursive placeholders resolution and no magic. Use toml like this article Reading config files the Go way. 'map.key'), To do so, you can use the enhancement possibilities of the library. mv fails with "No space left on device" when the destination has 31 GB of space remaining, Cannot handle OpenDirect push notification when iOS app is not launched. Environment variables are key-value pair on a system-wide level, and running processes can access that. // contains filtered or unexported fields, // parse env value. If you are using the code versioning tool like. I started using flags for a project I've been working on (my first from-scratch golang project), but I'm wondering how to handle things like tests? rev2022.7.21.42639. There are no such things like complex environment name generators based on nested structure names - you have to set names as-is, so you can easily find them using a search. Isn't this exactly what Ask mentioned already? // JSONMarshalIndent if not empty, will use json.MarshalIndent for encode data. First two just dont feel right and viper, imo, a little overcomplicateddefinitely offering too much for small things. Site Links: So its pretty clear how to get configs. Standard go flags have the following benefits: The only drawback standard go flags have - is management problems when the number of flags used in your app becomes too large. TODO refactor: rename GetDecoder() to Decode(), rename GetEncoder() to Encode(), Encoder for decode yml,json,toml format content, These are some sample code for YAML,TOML,JSON,INI,HCL, Package dotnev provide load .env data to os ENV Deprecated: please use github.com/gookit/ini/v2/dotenv, Package hcl is driver use HCL format content as config source about HCL, please see https://github.com/hashicorp/hcl, Package hclv2 is driver use HCL format content as config source about HCL, please see https://github.com/hashicorp/hcl docs for HCL v2 https://pkg.go.dev/github.com/hashicorp/hcl/v2, Package ini is driver use INI format content as config source about ini parse, please see https://github.com/gookit/ini/parser, Package json use the https://github.com/json-iterator/go for parse json, Package json5 use the https://github.com/yosuke-furukawa/json5 for parse json5, Package other is an example of a custom driver. You can manage multiple deployment environments like PROD, DEV, or TEST. And here we are: cleanenv library is now released and proven in production. But I hate having to create the struct of the exact fields and types I might be setting. The common problem is that the exact list of variables is often uncertain or outdated (or even worth, they are distributed through the app and being read in some unexpectable places). Initializing a new Go configuration with Viper. automatic mirror of https://git.sr.ht/~spc/go-ini. Our Product Experts will show you the power of the LoginRadius CIAM platform, discuss use-cases, and prove out ROI for your business. Learn on the go with our new app. goconfig uses a struct as input and populates the fields of this struct with parameters from command line, environment variables and configuration file. Also, feel free to request any features you think may be helpful. Im actively using it in my projects, so it is productive-proved. (Looks for config file in the config directory). ", "what are valid values for it?" Design: Initio by GetTemplate - But I want not only to give a simple tool but also to make it easy to use with other codes.

LoadRemote load config data from remote URL. String get a string by key, if not found return default value, Strings get config data as a string slice/array. LoadExists load and parse config files, but will ignore not exists file. I usually use JSON for more complicated data structures. The JSON format worked for me quite well.

Simple, lightweight, extensible, configuration management library for Go. But it works, it is pretty quick, and super simple to use. Here is an example of a simple server configuration structure: This structure can be used to parse YAML configuration file, and then read some data from the environment. modified, and redistributed. They are used to work with only one config file. You can now choose to sort by Trending, which boosts votes that have happened recently, helping to surface more up-to-date answers. the nice and informative help output; What is the best way to handle configuration of a service? Even if you define a structure instead of using an unsafe map, you still have to declare which environment variables do you use. See also https://groups.google.com/forum/#!topic/golang-nuts/TByzyPgoAQE for details.

Which is the best way to allow configuration options be overridden at the command line in Python? For file parsing, we are using the same approach as corresponding libraries - JSON, YAML, TOML, etc. bitbucket.org/gotamer/cfg is a json configuration package. Store is a dead simple configuration manager for Go applications. Personally i think it's easier for admins or customers to change a TOML file than a JSON.

Alternative to viper. About

Below is the list of functions related to environment variables and there uses. The structure (as deep and complex as you want) being used to parse configuration files and environment variables. Golang Example is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com. Are shrivelled chilis safe to eat and process into chili flakes? AddDriver set a decoder and encoder driver for a format. He has since then inculcated very effective writing and reviewing culture at golangexample which rivals have found impossible to imitate. Categories Recently I need an INI parser with section support, and I write a simple package: u can parse INI like using "flag" package: You might also be interested in go-libucl, a set of Go bindings for UCL, the Universal Configuration Language. Simplicity is everything. Some libraries (like viper store configs as a key-value set in a global area. Pretty useful, but very implicit. Maybe my background in dynamic languages makes me blind to the benefits of such verboseness. To me that was a pain. But it is designed to do a simple, clean and readable, but flexible enough if you need so. Here using the yaml format as an example(testdata/yml_other.yml): examples code please see _examples/yaml.go: Note: The default binding mapping tag of a structure is mapstructure, which can be changed by setting the decoder's option options.DecoderConfig.TagName. have a generic way to get all env variables define in your struct. Go isnt a language for everyone. For base configuration (api keys, port numbers, ) I've had very good luck with the gcfg package. But many developers does not want to manage 2 repository of information. How can recreate this bubble wrap effect on my photos? Why is rapid expansion/compression reversible? Now you can manage environment variables in your go application, and You can found the complete code used in this tutorial on our Github Repo, Very curious about this world and blogging whenever learning something new. Not a good idea when you need to share config with other pieces of application written in another languages. Using the LoginRadius Identity Platform, companies can offer a streamlined login process while protecting customer accounts and complying with data privacy regulations. Site design / logo 2022 Stack Exchange Inc; user contributions licensed under CC BY-SA. Documentation can be outdated, and source code needs time and skill to read. To add a new package, please, check the contribute section. JavaScript front end for Odin Project book library database. So the main idea is to get the application settings from where they are (file, env, remote server, etc.) MapStruct alias method of the 'Structure', ParseEnvVarStringHookFunc returns a DecodeHookFunc that parse ENV var, StringMap get config data as a map[string]string, Uint get a uint value, if not found return default value, NewWith create config instance, and you can call some init func. This script will find all of the configuration version left in TFC, Trivial proxy server that logs requests and responses to stdout, List Process In Table, Search and Filter by Name, PID, PPID, User. So we have to get information from the json : have a static configuration context allowing you to have all the configuration everywhere in your app. There are some ways to write your own logic to read the data from your own source. Do not miss the trending, packages, news and articles with our Go Newsletter default is '. But what to do next? // Environ returns a slice of string containing all the environment variables in the form of key=value. Below is the output when we run go run main.go in our terminal. ', // DecoderConfig setting for binding data to struct, (c) LoadExistsByFormat(format, sourceFiles), (c) LoadFilesByFormat(format, sourceFiles), https://github.com/JanDeDobbeleer/oh-my-posh, func BindStruct(key string, dst interface{}) error, func Bool(key string, defVal bool) bool, func DumpTo(out io.Writer, format string) (int64, error), func Exists(key string, findByPath bool) bool, func Float(key string, defVal float64) float64, func Get(key string, findByPath bool) interface{}, func GetEnv(name string, defVal string) (val string), func GetValue(key string, findByPath bool) (interface{}, bool), func Getenv(name string, defVal string) (val string), func Int64(key string, defVal int64) int64, func LoadData(dataSource interface{}) error, func LoadExists(sourceFiles string) error, func LoadExistsByFormat(format string, sourceFiles string) error, func LoadFiles(sourceFiles string) error, func LoadFilesByFormat(format string, sourceFiles string) error, func LoadOSEnv(keys []string, keyToLower bool), func LoadRemote(format, url string) error, func LoadSources(format string, src []byte, more []byte) error, func LoadStrings(format string, str string, more string) error, func MapOnExists(key string, dst interface{}) error, func MapStruct(key string, dst interface{}) error, func ParseEnvVarStringHookFunc() mapstructure.DecodeHookFunc, func Set(key string, val interface{}, setByPath bool) error, func SetData(data map[string]interface{}), func SetDecoder(format string, decoder Decoder), func SetEncoder(format string, encoder Encoder), func String(key string, defVal string) string, func StringMap(key string) map[string]string, func Uint(key string, defVal uint) uint, func WithHookFunc(fn HookFunc) func(*Options), func WriteTo(out io.Writer) (int64, error), func NewWith(name string, fn func(c *Config)) *Config, func NewWithOptions(name string, opts func(*Options)) *Config, func (c *Config) AddDriver(driver Driver), func (c *Config) BindStruct(key string, dst interface{}) error, func (c *Config) Bool(key string, defVal bool) (value bool), func (c *Config) Data() map[string]interface{}, func (c *Config) DelDriver(format string), func (c *Config) DumpTo(out io.Writer, format string) (n int64, err error), func (c *Config) Exists(key string, findByPath bool) (ok bool), func (c *Config) Float(key string, defVal float64) (value float64), func (c *Config) Get(key string, findByPath bool) interface{}, func (c *Config) GetValue(key string, findByPath bool) (value interface{}, ok bool), func (c *Config) HasDecoder(format string) bool, func (c *Config) HasEncoder(format string) bool, func (c *Config) Int(key string, defVal int) (value int), func (c *Config) Int64(key string, defVal int64) (value int64), func (c *Config) IntMap(key string) (mp map[string]int), func (c *Config) Ints(key string) (arr []int), func (c *Config) LoadData(dataSources interface{}) (err error), func (c *Config) LoadExists(sourceFiles string) (err error), func (c *Config) LoadExistsByFormat(format string, sourceFiles string) (err error), func (c *Config) LoadFiles(sourceFiles string) (err error), func (c *Config) LoadFilesByFormat(format string, sourceFiles string) (err error), func (c *Config) LoadFlags(keys []string) (err error), func (c *Config) LoadOSEnv(keys []string, keyToLower bool), func (c *Config) LoadRemote(format, url string) (err error), func (c *Config) LoadSources(format string, src []byte, more []byte) (err error), func (c *Config) LoadStrings(format string, str string, more string) (err error), func (c *Config) MapOnExists(key string, dst interface{}) error, func (c *Config) MapStruct(key string, dst interface{}) error, func (c *Config) Set(key string, val interface{}, setByPath bool) (err error), func (c *Config) SetData(data map[string]interface{}), func (c *Config) SetDecoder(format string, decoder Decoder), func (c *Config) SetDecoders(decoders map[string]Decoder), func (c *Config) SetEncoder(format string, encoder Encoder), func (c *Config) SetEncoders(encoders map[string]Encoder), func (c *Config) String(key string, defVal string) string, func (c *Config) StringMap(key string) (mp map[string]string), func (c *Config) Strings(key string) (arr []string), func (c *Config) Structure(key string, dst interface{}) error, func (c *Config) Uint(key string, defVal uint) (value uint), func (c *Config) With(fn func(c *Config)) *Config, func (c *Config) WithOptions(opts func(*Options)) *Config, func (c *Config) WriteTo(out io.Writer) (n int64, err error), func NewDriver(name string, dec Decoder, enc Encoder) *StdDriver, func (d *StdDriver) Decode(blob []byte, v interface{}) (err error), func (d *StdDriver) Encode(v interface{}) ([]byte, error). golang debug