lytics / confl Goto Github PK
View Code? Open in Web Editor NEWConfig parser for go, modeled after Nginx format, Nice lenient syntax with Comments
License: MIT License
Config parser for go, modeled after Nginx format, Nice lenient syntax with Comments
License: MIT License
panic: runtime error: slice bounds out of range
goroutine 1 [running]:
.../vendor/github.com/lytics/confl.maybeRemoveIndents(0xc4201394b2, 0x2a8, 0x20, 0xc420063af8)
.../vendor/github.com/lytics/confl/parse.go:304 +0x22b
.../vendor/github.com/lytics/confl.(*parser).processItem(0xc4200de4d0, 0x5, 0xc4201394b2, 0x2a8, 0x56, 0x0, 0x0)
.../vendor/github.com/lytics/confl/parse.go:170 +0x61b
vendor/github.com/lytics/confl.parse(0xc420139000, 0x75c, 0xc420139000, 0x0, 0x1520c40)
.../vendor/github.com/lytics/confl/parse.go:92 +0x322
vendor/github.com/lytics/confl.Decode(0xc420139000, 0x75c, 0x13093e0, 0x1520060, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
.../vendor/github.com/lytics/confl/decode.go:110 +0x7c
vendor/github.com/lytics/confl.DecodeFile(0x7ffeefbffb4b, 0xf, 0x13093e0, 0x1520060, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
..vendor/github.com/lytics/confl/decode.go:128 +0x16e
Courtesy of https://github.com/dvyukov/go-fuzz
I'll submit a pull request to include this in the tree next..
package main
import (
"fmt"
"github.com/lytics/confl"
)
func main() {
var v map[string]interface{}
fmt.Println("about to hang")
confl.Unmarshal([]byte("\x0e9\xbd\xbf\xefr"), &v)
fmt.Println("never gets here")
}
encoding/json and friends have an API in the style of
func Marshal(val interface{}) ([]byte, error)
func Unmarshal(data []byte, v interface{}) error
func NewEncoder(w io.Writer) *Encoder
func (enc *Encoder) Encode(v interface{}) error
func NewDecoder(r io.Reader) *Decoder
func (dec *Decoder) Decode(v interface{}) error
Where "decode" means streaming operations and "marshal" operates on []byte.
Why not follow that? Right now, the confl API seems unlike good Go, and especially Decode taking a string comes off as very weird.
Apart from that, looks good. I've been wanting something like this for a while, and while https://github.com/hashicorp/hcl also looked promising, it seems confl integrates with the Go style of unmarshaling into a struct better.
confl is machine editable and human readable which makes it an extremely useful tool. However, using a machine to edit a confl config results in the comments being lost.
$ cd $GOPATH/src/github.com/lytics/confl/_examples
$ go run example.go | tail -3
multi line text with a block paren
block ends with end paren on new line
)
This is even more obvious if you temporarily change the code to
fmt.Printf("Description: %q\n", config.Description)
Perhaps this would make sense. I can see a lot of callers wanting this; I did.
Inspiration:
Be careful to preserve inner indentation. That is:
foo (
# I am an embedded markdown article
Blah blah.
func code() {
// code inside markdown is indented more
}
)
Note that the #
there is not a comment, it's inside the string literal (this is already current confl behavior).
location ~* .(otf|eot|woff|ttf|woff2)$ {
types {font/opentype otf;}
types {application/vnd.ms-fontobject eot;}
types {font/truetype ttf;}
types {application/font-woff woff;}
types {font/woff2 woff2;}
}
location / {
try_files $uri $uri/ /index.html =404;
expires off;
add_header Cache-Control "no-cache, no-store, must-revalidate";
add_header Strict-Transport-Security "max-age=86400" always;
}
Just like nginx's configuration, how do i deal it ?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.