1
0
mirror of https://github.com/json-iterator/go.git synced 2025-02-07 19:30:06 +02:00

fix go report card

This commit is contained in:
Tao Wen 2017-07-09 11:10:44 +08:00
parent 37ba1b32b5
commit 711f836582
3 changed files with 9 additions and 12 deletions

View File

@ -1,10 +1,8 @@
package jsoniter_test
package jsoniter
import (
"fmt"
"os"
"github.com/json-iterator/go"
)
func ExampleMarshal() {
@ -18,7 +16,7 @@ func ExampleMarshal() {
Name: "Reds",
Colors: []string{"Crimson", "Red", "Ruby", "Maroon"},
}
b, err := jsoniter.Marshal(group)
b, err := Marshal(group)
if err != nil {
fmt.Println("error:", err)
}
@ -37,7 +35,7 @@ func ExampleUnmarshal() {
Order string
}
var animals []Animal
err := jsoniter.Unmarshal(jsonBlob, &animals)
err := Unmarshal(jsonBlob, &animals)
if err != nil {
fmt.Println("error:", err)
}
@ -57,8 +55,8 @@ func ExampleMarshalWithBestPerformance() {
Name: "Reds",
Colors: []string{"Crimson", "Red", "Ruby", "Maroon"},
}
stream := jsoniter.ConfigFastest.BorrowStream(nil)
defer jsoniter.ConfigFastest.ReturnStream(stream)
stream := ConfigFastest.BorrowStream(nil)
defer ConfigFastest.ReturnStream(stream)
stream.WriteVal(group)
if stream.Error != nil {
fmt.Println("error:", stream.Error)
@ -78,8 +76,8 @@ func ExampleUnmarshalWithBestPerformance() {
Order string
}
var animals []Animal
iter := jsoniter.ConfigFastest.BorrowIterator(jsonBlob)
defer jsoniter.ConfigFastest.ReturnIterator(iter)
iter := ConfigFastest.BorrowIterator(jsonBlob)
defer ConfigFastest.ReturnIterator(iter)
iter.ReadVal(&animals)
if iter.Error != nil {
fmt.Println("error:", iter.Error)
@ -91,7 +89,7 @@ func ExampleUnmarshalWithBestPerformance() {
func ExampleOneLine() {
val := []byte(`{"ID":1,"Name":"Reds","Colors":["Crimson","Red","Ruby","Maroon"]}`)
fmt.Printf(jsoniter.Get(val, "Colors", 0).ToString())
fmt.Printf(Get(val, "Colors", 0).ToString())
// Output:
// Crimson
}

View File

@ -21,7 +21,6 @@ func (any *invalidAny) ValueType() ValueType {
func (any *invalidAny) MustBeValid() Any {
panic(any.err)
return any
}
func (any *invalidAny) ToBool() bool {

View File

@ -381,7 +381,7 @@ func Test_mixed(t *testing.T) {
type AA struct {
ID int `json:"id"`
Payload map[string]interface{} `json:"payload"`
buf *bytes.Buffer `json:"-"`
buf *bytes.Buffer
}
aa := AA{}
err := UnmarshalFromString(` {"id":1, "payload":{"account":"123","password":"456"}}`, &aa)