kylelemons / go-gypsy Goto Github PK
View Code? Open in Web Editor NEWGo YAML Parser for Simple YAML
License: Apache License 2.0
Go YAML Parser for Simple YAML
License: Apache License 2.0
Add support for the | and > multiline strings.
When I run gotest, it fails on TestLineBreak, because Line.BreakAt() has been removed.
Hello. I'm try to parse app.yaml appengine like file with this package and stopped at getting type List, for example i have this file
application: xxxx
version: 1
runtime: go
api_version: go1
handlers:
- url: /static
static_dir: static/
upload: static/
- url: /.*
script: _go_app
How can i get handlers to iterate in for cycle?
Consider the below exmaple,
Load:
- Testts.add:
- Name: |
xline1
xline2
- Name: |
yline1
yline2
I have used two multiline string values. When the above string is parsed, the first multi line string is not terminated after the indentation level is reduced ie, "xline1\nxline2\n- Name: |\nyline1\nyline2" is formed as single string and assigned as value to Name key and only one item is added in the list (for key Testts.add).
Ok, I've beat my head against the wall with this yaml thing all night. I have this yaml here.
bot:
server: irc.rizon.net
port: 6667
nick: botname
identpass: somepass
password: anotherpass
channels:
- #channel1
- #channel2
- #channel3
I am trying to get a list of channels I can iterate through, but I can't manage to get the yaml parser to return a list I can only access single elements.
I want to have a string value, which contains ":" inside.
The following yaml:
addr: localhost:8000
is interpreted as {"addr": {"localhost": 8000}}. Whereas
addr: "localhost:8000"
as {"addr": ""localhost:8000""}.
I need {"addr": "localhost:8000"}
Write a formal specification of the subset of YAML understood by Gypsy
First off, thanks for this tool.
I was trying to parse a simple yaml file like the one below and I couldn't find a helpful example.
- Ghana
- Mali
- Togo
I had to experiment several times before l I was able to parse it.
It would be nice if you added more examples. (I'm willing to contribute)
If anyone's interested in how I solved my problem ๐๐พ
config, err := yaml.ReadFile("/database/seeds/countries.yml")
if err != nil {
panic(err)
}
lst, ok := config.Root.(yaml.List)
if !ok {
panic("failed to parse")
}
for i := 0; i < lst.Len(); i++ {
item := lst.Item(i)
fmt.Println(item)
}
in getType(), should use "- " not '-' to check if it's a List.
There are a couple of issues with multi-line strings support:
Multi-line strings aren't rendered correctly.
Nested multi line strings don't work. Parsing this fails:
google:
company: Google, Inc.
ticker: GOOG
description: |
I
am
Google
url: http://google.com/
(for some reason github is not showing the proper indents here, but you get the idea)
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.