1
0
mirror of https://github.com/json-iterator/go.git synced 2025-04-20 11:28:49 +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 ( import (
"fmt" "fmt"
"os" "os"
"github.com/json-iterator/go"
) )
func ExampleMarshal() { func ExampleMarshal() {
@ -18,7 +16,7 @@ func ExampleMarshal() {
Name: "Reds", Name: "Reds",
Colors: []string{"Crimson", "Red", "Ruby", "Maroon"}, Colors: []string{"Crimson", "Red", "Ruby", "Maroon"},
} }
b, err := jsoniter.Marshal(group) b, err := Marshal(group)
if err != nil { if err != nil {
fmt.Println("error:", err) fmt.Println("error:", err)
} }
@ -37,7 +35,7 @@ func ExampleUnmarshal() {
Order string Order string
} }
var animals []Animal var animals []Animal
err := jsoniter.Unmarshal(jsonBlob, &animals) err := Unmarshal(jsonBlob, &animals)
if err != nil { if err != nil {
fmt.Println("error:", err) fmt.Println("error:", err)
} }
@ -57,8 +55,8 @@ func ExampleMarshalWithBestPerformance() {
Name: "Reds", Name: "Reds",
Colors: []string{"Crimson", "Red", "Ruby", "Maroon"}, Colors: []string{"Crimson", "Red", "Ruby", "Maroon"},
} }
stream := jsoniter.ConfigFastest.BorrowStream(nil) stream := ConfigFastest.BorrowStream(nil)
defer jsoniter.ConfigFastest.ReturnStream(stream) defer ConfigFastest.ReturnStream(stream)
stream.WriteVal(group) stream.WriteVal(group)
if stream.Error != nil { if stream.Error != nil {
fmt.Println("error:", stream.Error) fmt.Println("error:", stream.Error)
@ -78,8 +76,8 @@ func ExampleUnmarshalWithBestPerformance() {
Order string Order string
} }
var animals []Animal var animals []Animal
iter := jsoniter.ConfigFastest.BorrowIterator(jsonBlob) iter := ConfigFastest.BorrowIterator(jsonBlob)
defer jsoniter.ConfigFastest.ReturnIterator(iter) defer ConfigFastest.ReturnIterator(iter)
iter.ReadVal(&animals) iter.ReadVal(&animals)
if iter.Error != nil { if iter.Error != nil {
fmt.Println("error:", iter.Error) fmt.Println("error:", iter.Error)
@ -91,7 +89,7 @@ func ExampleUnmarshalWithBestPerformance() {
func ExampleOneLine() { func ExampleOneLine() {
val := []byte(`{"ID":1,"Name":"Reds","Colors":["Crimson","Red","Ruby","Maroon"]}`) 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: // Output:
// Crimson // Crimson
} }

View File

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

View File

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