README ¶
candiedyaml
DEPRECATION NOTICE
The candiedyaml
library is no longer under active development and will soon
be moved to the cloudfoundry-attic
GitHub organization. We recommend the use of an alternative library such as
gopkg.in/yaml.v2
instead.
YAML for Go
A YAML 1.1 parser with support for YAML 1.2 features
Usage
package myApp
import (
"github.com/cloudfoundry-incubator/candiedyaml"
"fmt"
"os"
)
func main() {
file, err := os.Open("path/to/some/file.yml")
if err != nil {
println("File does not exist:", err.Error())
os.Exit(1)
}
defer file.Close()
document := new(interface{})
decoder := candiedyaml.NewDecoder(file)
err = decoder.Decode(document)
if err != nil {
println("Failed to decode document:", err.Error())
}
println("parsed yml into interface:", fmt.Sprintf("%#v", document))
fileToWrite, err := os.Create("path/to/some/new/file.yml")
if err != nil {
println("Failed to open file for writing:", err.Error())
os.Exit(1)
}
defer fileToWrite.Close()
encoder := candiedyaml.NewEncoder(fileToWrite)
err = encoder.Encode(document)
if err != nil {
println("Failed to encode document:", err.Error())
os.Exit(1)
}
return
}
Documentation ¶
Index ¶
Constants ¶
View Source
const ( BOM_UTF8 = "\xef\xbb\xbf" BOM_UTF16LE = "\xff\xfe" BOM_UTF16BE = "\xfe\xff" )
* Byte order marks.
View Source
const ( INPUT_RAW_BUFFER_SIZE = 1024 /* * The size of the input buffer. * * It should be possible to decode the whole raw buffer. */ INPUT_BUFFER_SIZE = (INPUT_RAW_BUFFER_SIZE * 3) OUTPUT_BUFFER_SIZE = 512 OUTPUT_RAW_BUFFER_SIZE = (OUTPUT_BUFFER_SIZE*2 + 2) INITIAL_STACK_SIZE = 16 INITIAL_QUEUE_SIZE = 16 )
View Source
const MAX_NUMBER_LENGTH = 9
Variables ¶
This section is empty.
Functions ¶
func Run_parser ¶
Types ¶
type Encoder ¶
type Encoder struct {
// contains filtered or unexported fields
}
An Encoder writes JSON objects to an output stream.
func NewEncoder ¶
NewEncoder returns a new encoder that writes to w.
type Number ¶
type Number string
A Number represents a JSON number literal.
type ParserError ¶
type ParserError struct { ErrorType YAML_error_type_t Context string ContextMark YAML_mark_t Problem string ProblemMark YAML_mark_t }
func (*ParserError) Error ¶
func (e *ParserError) Error() string
type UnexpectedEventError ¶
type UnexpectedEventError struct { Value string EventType yaml_event_type_t At YAML_mark_t }
func (*UnexpectedEventError) Error ¶
func (e *UnexpectedEventError) Error() string
type Unmarshaler ¶
type YAML_error_type_t ¶
type YAML_error_type_t int
* Many bad things could happen with the parser and emitter.
type YAML_mark_t ¶
type YAML_mark_t struct {
// contains filtered or unexported fields
}
* The pointer position.
func (YAML_mark_t) String ¶
func (m YAML_mark_t) String() string
Click to show internal directories.
Click to hide internal directories.