Skip to content

wedoca/consul_client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 

Repository files navigation

Consul Client

This package allows you to unpack data in a json format into the structure.

There is support for specifying symbolic links.

Usage

package main

import (
	"fmt"
	"github.com/wedoca/consul_client"
)

type MyConfig struct {
	HostName  string   `json:"host_name"`
	FirstName string   `json:"first_name"`
	Data      []string `json:"data"`
}

func main() {
	
	//	raw data in consul KV:
	//	{
	//		"host_name": "localhost",
	//		"first_name.link": "some_path/folder/folder/key",
	//		"data": ["a", "b", "c"]
	//	}
	
	m := &MyConfig{}
	_, err := consul_client.ConsulClient("/first_path/key", m)
	if err != nil {
		fmt.Println(err)
		return
	}
	
	// or
	myStringValue, err := consul_client.ConsulClient("/second_path/key_with_simple_string_value", nil)
	if err != nil {
		fmt.Println(err)
	}
	
	fmt.Println("my string value:", myStringValue)

}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages