![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
go.krak3n.codes/gofig/parsers/yaml
This parser loads yaml
formatted configuration from an io.ReadCloser
.
Click the Playground badge above to see the example running in the Go Playground.
package main
import (
"fmt"
"io/ioutil"
"go.krak3n.codes/gofig"
"go.krak3n.codes/gofig/parsers/yaml"
)
// Config is a struct to unpack configuration into.
type Config struct {
Foo struct {
Bar struct {
Baz string `gofig:"baz"`
} `gofig:"bar"`
} `gofig:"foo"`
Fizz struct {
Buzz map[string]string `gofig:"buzz"`
} `gofig:"fizz"`
A struct {
B map[string][]int `gofig:"b"`
} `gofig:"a"`
C struct {
D map[string]map[string][]int `gofig:"d"`
} `gofig:"c"`
}
const blob string = `
foo:
bar:
baz: bar
fizz:
buzz:
hello: world
bill: ben`
func main() {
var cfg Config
// Initialise gofig with the struct config values will be placed into
gfg, err := gofig.New(&cfg)
gofig.Must(err)
// Create a parser
parser := yaml.New()
// write some data to a config file
path, err := create()
gofig.Must(err)
// Parse in order
gofig.Must(gfg.Parse(
gofig.FromFile(parser, path),
gofig.FromString(parser, blob)))
fmt.Println(fmt.Sprintf("%+v", cfg))
}
const contents = `
a:
b:
c: [1,2,3]
c:
d:
e:
f: [1,2,3]`
func create() (string, error) {
f, err := ioutil.TempFile("", "yaml")
if err != nil {
return "", err
}
if _, err := f.Write([]byte(contents)); err != nil {
return "", err
}
return f.Name(), nil
}
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.