Skip to content

json.Unmarshal did not work #21715

@kingangelAOA

Description

@kingangelAOA

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

version : 1.9

Does this issue reproduce with the latest release?

What operating system and processor architecture are you using (go env)?

mac 10.12

What did you do?

         for index, url := range URLS {
	fmt.Println(index)
	iface.Hosts = []string{url}
	res, err := iface.Request()
	if err != nil {
		panic(err)
	}
	if res.StatusCode == 200 {
		body, err := ioutil.ReadAll(res.Body)
		if err != nil {
			panic(err)
		}
		var eleSoaResponse EleSoaResponse
		if err := json.Unmarshal(body, &eleSoaResponse); err != nil {
			panic(err)
		}
		var rankResponse RankResponse
		fmt.Println("begin json Unmarshal", len(eleSoaResponse.Result))
		if err := json.Unmarshal([]byte(eleSoaResponse.Result), &rankResponse); err != nil {
			fmt.Println("json Unmarshal err")
			panic(err)
		}
		fmt.Println("end json Unmarshal")
		if index == 0 {
			resMap["xg"] = rankResponse
		} else {
			resMap["wg"] = rankResponse
		}
	} else {
		body, err := ioutil.ReadAll(res.Body)
		if err != nil {
			panic(err)
		}
		panic(fmt.Errorf("request error, status: %d, body: %s", res.StatusCode, string(body)))
	}
      }

What did you expect to see?

0
begin json Unmarshal 97997
end json Unmarshal
1
begin json Unmarshal 97997
end json Unmarshal

What did you see instead?

0
begin json Unmarshal 97997
end json Unmarshal
1
begin json Unmarshal 97997

it is pending and json.Unmarshal did not catch error

eleSoaResponse.Result is too big

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeWaitingForInfoIssue is not actionable because of missing required information, which needs to be provided.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions