// The original error message returned by stdlib changed with go1.8.
// We only test the latest release.
//
//+build go1.8 forcego1.8

package jsonptrerror_test

import (
	"fmt"
	"strings"

	"github.com/dolmen-go/jsonptrerror"
)

func ExampleDecoder() {
	decoder := jsonptrerror.NewDecoder(strings.NewReader(
		`{"key": "x", "value": 5}`,
	))
	var out struct {
		Key   string `json:"key"`
		Value bool   `json:"value"`
	}
	err := decoder.Decode(&out)
	fmt.Println(err)
	if err, ok := err.(*jsonptrerror.UnmarshalTypeError); ok {
		//fmt.Println("Original error:", err.UnmarshalTypeError.Error())
		fmt.Println("Error location:", err.Pointer)
	}

	// Output:
	// /value: cannot unmarshal number into Go value of type bool
	// Error location: /value
}

// The original error message returned by stdlib changed with go1.8.
// We only test the latest release.
//
//+build go1.8 forcego1.8

package jsonptrerror_test

import (
	"fmt"
	"strings"

	"github.com/dolmen-go/jsonptrerror"
)

func ExampleDecoder() {
	decoder := jsonptrerror.NewDecoder(strings.NewReader(
		`{"key": "x", "value": 5}`,
	))
	var out struct {
		Key   string `json:"key"`
		Value bool   `json:"value"`
	}
	err := decoder.Decode(&out)
	fmt.Println(err)
	if err, ok := err.(*jsonptrerror.UnmarshalTypeError); ok {
		fmt.Println("Original error:", err.UnmarshalTypeError.Error())
		fmt.Println("Error location:", err.Pointer)
	}

	// Output:
	// /value: cannot unmarshal number into Go value of type bool
	// Original error: json: cannot unmarshal number into Go struct field .value of type bool
	// Error location: /value
}

--- 
+++ 
@@ -23,12 +23,11 @@
 	err := decoder.Decode(&out)
 	fmt.Println(err)
 	if err, ok := err.(*jsonptrerror.UnmarshalTypeError); ok {
-		fmt.Println("Original error:", err.UnmarshalTypeError.Error())
+		//fmt.Println("Original error:", err.UnmarshalTypeError.Error())
 		fmt.Println("Error location:", err.Pointer)
 	}
 
 	// Output:
 	// /value: cannot unmarshal number into Go value of type bool
-	// Original error: json: cannot unmarshal number into Go struct field .value of type bool
 	// Error location: /value
 }
Fix Example to not show the original error (which is go version dependent)
