shogo82148 / androidbinary

Android binary file parser written in golang
MIT License
241 stars 79 forks source link

support Go1.8, and drop support Go1.1 #5

Closed shogo82148 closed 7 years ago

shogo82148 commented 7 years ago

tests fail on travis Go 1.8... Why??

ok      github.com/shogo82148/androidbinary 0.011s
=== RUN   TestGetIcon
--- FAIL: TestGetIcon (0.00s)
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
    panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x684509]
goroutine 5 [running]:
testing.tRunner.func1(0xc420064ea0)
    /home/travis/.gimme/versions/go1.8.linux.amd64/src/testing/testing.go:622 +0x29d
panic(0x6d03a0, 0x88d860)
    /home/travis/.gimme/versions/go1.8.linux.amd64/src/runtime/panic.go:489 +0x2cf
github.com/shogo82148/androidbinary/apk.OpenFile(0x72db12, 0x17, 0x0, 0x865e00, 0xc420126ca0)
    /home/travis/gopath/src/github.com/shogo82148/androidbinary/apk/apk.go:47 +0x139
github.com/shogo82148/androidbinary/apk.TestGetIcon(0xc420064ea0)
    /home/travis/gopath/src/github.com/shogo82148/androidbinary/apk/apk_test.go:10 +0x4b
testing.tRunner(0xc420064ea0, 0x738c28)
    /home/travis/.gimme/versions/go1.8.linux.amd64/src/testing/testing.go:657 +0x96
created by testing.(*T).Run
    /home/travis/.gimme/versions/go1.8.linux.amd64/src/testing/testing.go:697 +0x2ca
FAIL    github.com/shogo82148/androidbinary/apk 0.007s
codeskyblue commented 7 years ago

Tested on windows go 1.8.1 test can pass.

λ go test -v
=== RUN   TestGetIcon
--- PASS: TestGetIcon (0.01s)
        apk_test.go:20: app label: HelloWorld
PASS
ok      github.com/codeskyblue/androidbinary/apk        0.208s

Maybe can be fixed by set go version to 1.8.1, not 1.8

codeskyblue commented 7 years ago

Also tested on linux/amd64 debian7 go 1.8.1, test passed.

codeskyblue commented 7 years ago

Great

shogo82148 commented 7 years ago

The following code doesn't report any error in my environment(go version go1.8.1 darwin/amd64)... Why??

package main

import (
    "encoding/xml"
    "fmt"
)

type Elem struct {
    Attr int `xml:"attr,attr"`
}

func main() {
    var elem Elem
    xmldata := `<elem attr="@0x7F08008E"></elem>`
    fmt.Println(xml.Unmarshal([]byte(xmldata), &elem))
    fmt.Printf("%+v\n", elem)
}

But, Go Playground reports strconv.ParseInt: parsing "@0x7F08008E": invalid syntax https://play.golang.org/p/36_S_scN_X

fujiwara commented 7 years ago

FYI Results of my environment are below.

go version go1.8 darwin/amd64 => strconv.ParseInt: parsing "@0x7F08008E": invalid syntax
go version go1.8.1 darwin/amd64 => <nil>
go version go1.7.3 linux/amd64 => <nil>
go version go1.8.1 linux/amd64 => <nil>
shogo82148 commented 7 years ago

Thank you!

I found it!

// For Go 1.8.1 we've restored the old "no errors reported" behavior.
// We'll try again in Go 1.9 to report errors.