summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/pelletier
diff options
context:
space:
mode:
authorChristopher Speller <crspeller@gmail.com>2017-08-17 17:19:06 -0700
committerGitHub <noreply@github.com>2017-08-17 17:19:06 -0700
commit96eab1202717e073782ec399a4e0820cae15b1bb (patch)
tree011012982be971c7e9ef91466f026bc0956ac9a2 /vendor/github.com/pelletier
parent2c895ee66eed626721135acfcc48254c6e3f3b29 (diff)
downloadchat-96eab1202717e073782ec399a4e0820cae15b1bb.tar.gz
chat-96eab1202717e073782ec399a4e0820cae15b1bb.tar.bz2
chat-96eab1202717e073782ec399a4e0820cae15b1bb.zip
Updating server dependancies. (#7246)
Diffstat (limited to 'vendor/github.com/pelletier')
-rw-r--r--vendor/github.com/pelletier/go-toml/doc_test.go55
-rw-r--r--vendor/github.com/pelletier/go-toml/marshal_test.go19
2 files changed, 51 insertions, 23 deletions
diff --git a/vendor/github.com/pelletier/go-toml/doc_test.go b/vendor/github.com/pelletier/go-toml/doc_test.go
index 9dd773899..a48c04b01 100644
--- a/vendor/github.com/pelletier/go-toml/doc_test.go
+++ b/vendor/github.com/pelletier/go-toml/doc_test.go
@@ -1,13 +1,16 @@
// code examples for godoc
-package toml
+package toml_test
import (
"fmt"
+ "log"
+
+ toml "github.com/pelletier/go-toml"
)
func Example_tree() {
- config, err := LoadFile("config.toml")
+ config, err := toml.LoadFile("config.toml")
if err != nil {
fmt.Println("Error ", err.Error())
@@ -17,7 +20,7 @@ func Example_tree() {
password := config.Get("postgres.password").(string)
// or using an intermediate object
- configTree := config.Get("postgres").(*Tree)
+ 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)
@@ -48,6 +51,50 @@ func Example_unmarshal() {
`)
person := Person{}
- Unmarshal(document, &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"`
+ }
+ type Config struct {
+ Postgres Postgres `toml:"postgres"`
+ }
+
+ config := Config{Postgres{User: "pelletier", Password: "mypassword"}}
+ b, err := toml.Marshal(config)
+ if err != nil {
+ log.Fatal(err)
+ }
+ fmt.Println(string(b))
+ // Output:
+ // [postgres]
+ // 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
}
diff --git a/vendor/github.com/pelletier/go-toml/marshal_test.go b/vendor/github.com/pelletier/go-toml/marshal_test.go
index a3fa128d2..dbfc7c1d1 100644
--- a/vendor/github.com/pelletier/go-toml/marshal_test.go
+++ b/vendor/github.com/pelletier/go-toml/marshal_test.go
@@ -177,25 +177,6 @@ func TestDocUnmarshal(t *testing.T) {
}
}
-func ExampleUnmarshal() {
- type Postgres struct {
- User string
- Password string
- }
- type Config struct {
- Postgres Postgres
- }
-
- doc := []byte(`
- [postgres]
- user = "pelletier"
- password = "mypassword"`)
-
- config := Config{}
- Unmarshal(doc, &config)
- fmt.Println("user=", config.Postgres.User)
-}
-
func TestDocPartialUnmarshal(t *testing.T) {
result := testDocSubs{}