summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/pelletier/go-toml/doc_test.go
diff options
context:
space:
mode:
authorChristopher Speller <crspeller@gmail.com>2018-04-16 05:37:14 -0700
committerJoram Wilander <jwawilander@gmail.com>2018-04-16 08:37:14 -0400
commit6e2cb00008cbf09e556b00f87603797fcaa47e09 (patch)
tree3c0eb55ff4226a3f024aad373140d1fb860a6404 /vendor/github.com/pelletier/go-toml/doc_test.go
parentbf24f51c4e1cc6286885460672f7f449e8c6f5ef (diff)
downloadchat-6e2cb00008cbf09e556b00f87603797fcaa47e09.tar.gz
chat-6e2cb00008cbf09e556b00f87603797fcaa47e09.tar.bz2
chat-6e2cb00008cbf09e556b00f87603797fcaa47e09.zip
Depenancy upgrades and movign to dep. (#8630)
Diffstat (limited to 'vendor/github.com/pelletier/go-toml/doc_test.go')
-rw-r--r--vendor/github.com/pelletier/go-toml/doc_test.go105
1 files changed, 0 insertions, 105 deletions
diff --git a/vendor/github.com/pelletier/go-toml/doc_test.go b/vendor/github.com/pelletier/go-toml/doc_test.go
deleted file mode 100644
index 3b8171b22..000000000
--- a/vendor/github.com/pelletier/go-toml/doc_test.go
+++ /dev/null
@@ -1,105 +0,0 @@
-// code examples for godoc
-
-package toml_test
-
-import (
- "fmt"
- "log"
-
- toml "github.com/pelletier/go-toml"
-)
-
-func Example_tree() {
- config, err := toml.LoadFile("config.toml")
-
- if err != nil {
- fmt.Println("Error ", err.Error())
- } else {
- // retrieve data directly
- user := config.Get("postgres.user").(string)
- password := config.Get("postgres.password").(string)
-
- // or using an intermediate object
- configTree := config.Get("postgres").(*toml.Tree)
- user = configTree.Get("user").(string)
- password = configTree.Get("password").(string)
- fmt.Println("User is", user, " and password is", password)
-
- // show where elements are in the file
- fmt.Printf("User position: %v\n", configTree.GetPosition("user"))
- fmt.Printf("Password position: %v\n", configTree.GetPosition("password"))
- }
-}
-
-func Example_unmarshal() {
- type Employer struct {
- Name string
- Phone string
- }
- type Person struct {
- Name string
- Age int64
- Employer Employer
- }
-
- document := []byte(`
- name = "John"
- age = 30
- [employer]
- name = "Company Inc."
- phone = "+1 234 567 89012"
- `)
-
- person := Person{}
- toml.Unmarshal(document, &person)
- fmt.Println(person.Name, "is", person.Age, "and works at", person.Employer.Name)
- // Output:
- // John is 30 and works at Company Inc.
-}
-
-func ExampleMarshal() {
- type Postgres struct {
- User string `toml:"user"`
- Password string `toml:"password"`
- Database string `toml:"db" commented:"true" comment:"not used anymore"`
- }
- type Config struct {
- Postgres Postgres `toml:"postgres" comment:"Postgres configuration"`
- }
-
- config := Config{Postgres{User: "pelletier", Password: "mypassword", Database: "old_database"}}
- b, err := toml.Marshal(config)
- if err != nil {
- log.Fatal(err)
- }
- fmt.Println(string(b))
- // Output:
- // # Postgres configuration
- // [postgres]
- //
- // # not used anymore
- // # db = "old_database"
- // password = "mypassword"
- // user = "pelletier"
-}
-
-func ExampleUnmarshal() {
- type Postgres struct {
- User string
- Password string
- }
- type Config struct {
- Postgres Postgres
- }
-
- doc := []byte(`
- [postgres]
- user = "pelletier"
- password = "mypassword"`)
-
- config := Config{}
- toml.Unmarshal(doc, &config)
- fmt.Println("user=", config.Postgres.User)
- // Output:
- // user= pelletier
-}