Product Promotion
0x5a.live
for different kinds of informations and explorations.
GitHub - gurkankaymak/hocon: go implementation of lightbend's HOCON configuration library https://github.com/lightbend/config
go implementation of lightbend's HOCON configuration library https://github.com/lightbend/config - gurkankaymak/hocon
Visit SiteGitHub - gurkankaymak/hocon: go implementation of lightbend's HOCON configuration library https://github.com/lightbend/config
go implementation of lightbend's HOCON configuration library https://github.com/lightbend/config - gurkankaymak/hocon
Powered by 0x5a.live ๐
HOCON (Human-Optimized Config Object Notation)
Configuration library for working with the Lightbend's HOCON format. HOCON is a human-friendly JSON superset
Features of HOCON
- Comments, with
#
or//
- Allow omitting the
{}
around a root object - Allow
=
as a synonym for:
- Allow omitting the
=
or:
before a{
sofoo { a : 42 }
- Allow omitting commas as long as there's a newline
- Allow trailing commas after last element in objects and arrays
- Allow unquoted strings for keys and values
- Unquoted keys can use dot-notation for nested objects,
foo.bar=42
meansfoo { bar : 42 }
- Duplicate keys are allowed; later values override earlier, except for object-valued keys where the two objects are merged recursively
include
feature merges root object in another file into current object, sofoo { include "bar.json" }
merges keys inbar.json
into the objectfoo
- substitutions
foo : ${a.b}
sets keyfoo
to the same value as theb
field in thea
object - substitutions concatenate into unquoted strings,
foo : the quick ${colors.fox} jumped
- substitutions fall back to environment variables if they don't
resolve in the config itself, so
${HOME}
would work as you expect. - substitutions normally cause an error if unresolved, but
there is a syntax
${?a.b}
to permit them to be missing. +=
syntax to append elements to arrays,path += "/bin"
- multi-line strings with triple quotes as in Python or Scala
see the documentation for more details about the HOCON https://github.com/lightbend/config/blob/master/HOCON.md
Installation
go get -u github.com/gurkankaymak/hocon
Usage
package main
import (
"fmt"
"log"
"github.com/gurkankaymak/hocon"
)
func main() {
hoconString := `
booleans {
trueVal: true
trueValAgain: ${booleans.trueVal}
trueWithYes: yes
falseWithNo: no
}
// this is a comment
# this is also a comment
numbers {
intVal: 3
floatVal: 1.0
}
strings {
a: "a"
b: "b"
c: "c"
}
arrays {
empty: []
ofInt: [1, 2, 3]
ofString: [${strings.a}, ${strings.b}, ${strings.c}]
ofDuration: [1 second, 2h, 3 days]
}
durations {
second: 1s
halfSecond: 0.5 second
minutes: 5 minutes
hours: 2hours
day: 1d
}
objects {
valueObject {
mandatoryValue: "mandatoryValue"
arrayValue: ${arrays.ofInt}
nullValue: null
}
}`
conf, err := hocon.ParseString(hoconString)
if err != nil {
log.Fatal("error while parsing configuration: ", err)
}
objectValue := conf.GetObject("objects.valueObject")
arrayValue := conf.GetArray("arrays.ofInt")
stringValue := conf.GetString("strings.a")
intValue := conf.GetInt("numbers.intVal")
floatValue := conf.GetFloat64("numbers.floatVal")
durationValue := conf.GetDuration("durations.second")
fmt.Println("objectValue:", objectValue) // {mandatoryValue:mandatoryValue, arrayValue:[1,2,3], nullValue:null}
fmt.Println("arrayValue:", arrayValue) // [1,2,3]
fmt.Println("stringValue:", stringValue) // a
fmt.Println("intValue:", intValue) // 3
fmt.Println("floatValue:", floatValue) // 1.0
fmt.Println("durationValue:", durationValue) // 1s
fmt.Println("all configuration:", conf)
}
GoLang Resources
are all listed below.
GitHub - GuilhermeCaruso/anko: :crystal_ball: Simple application watcher
resource
~/github.com
resource
GitHub - jidicula/go-fuzz-action: GitHub Action for Go 1.18 fuzz testing
resource
~/github.com
resource
GitHub - tucnak/climax: Climax is an alternative CLI with the human face
resource
~/github.com
resource
GitHub - lawrencewoodman/roveralls: A Go recursive coverage testing tool
resource
~/github.com
resource
GitHub - nakagami/firebirdsql: Firebird RDBMS sql driver for Go (golang)
resource
~/github.com
resource
GitHub - liweiyi88/onedump: Effortlessly database dump with one command.
resource
~/github.com
resource
GitHub - beefsack/go-astar: Go implementation of the A* search algorithm
resource
~/github.com
resource
GitHub - lxn/walk: A Windows GUI toolkit for the Go Programming Language
resource
~/github.com
resource
GitHub - mongodb/mongo-go-driver: The Official Golang driver for MongoDB
resource
~/github.com
resource
GitHub - bykof/gostradamus: Gostradamus: Better DateTimes for Go ๐ฐ๏ธ
resource
~/github.com
resource
GitHub - mozillazg/go-unidecode: ASCII transliterations of Unicode text.
resource
~/github.com
resource
GitHub - bolknote/go-gd: Go bingings for GD (http://www.boutell.com/gd/)
resource
~/github.com
resource
GitHub - mosajjal/dnsmonster: Passive DNS Capture and Monitoring Toolkit
resource
~/github.com
resource
GitHub - haxpax/gosms: :mailbox_closed: Your own local SMS gateway in Go
resource
~/github.com
resource
GitHub - wajox/gobase: This is a simple skeleton for golang applications
resource
~/github.com
resource
GitHub - VividCortex/gohistogram: Streaming approximate histograms in Go
resource
~/github.com
resource
GitHub - malaschitz/randomForest: Random Forest implementation in golang
resource
~/github.com
resource
GitHub - google/gopacket: Provides packet processing capabilities for Go
resource
~/github.com
resource
GitHub - khezen/evoli: Genetic Algorithm and Particle Swarm Optimization
resource
~/github.com
resource
GitHub - didip/tollbooth: Simple middleware to rate-limit HTTP requests.
resource
~/github.com
resource
GitHub - mustafaakin/gongular: A different approach to Go web frameworks
resource
~/github.com
resource
GitHub - songgao/colorgo: Colorize (highlight) `go build` command output
resource
~/github.com
resource
Made with โค๏ธ
to provide different kinds of informations and resources.