From 0ca5d04e6d16d26319d23b12f19423f678cf021f Mon Sep 17 00:00:00 2001 From: Yuji Yaginuma Date: Fri, 22 Sep 2023 10:07:34 +0900 Subject: [PATCH 1/2] Migrate CI to GitHub Actions --- .github/workflows/ci.yml | 33 +++++++++++++++++++++++++++++++++ .travis.yml | 16 ---------------- 2 files changed, 33 insertions(+), 16 deletions(-) create mode 100644 .github/workflows/ci.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..08a0e25 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,33 @@ +name: CI +on: + push: + branches: + - master + + pull_request: + +jobs: + test: + strategy: + matrix: + go-version: ["1.19", "1.20", "1.21"] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-go@v4 + with: + go-version: ${{ matrix.go-version }} + - run: go test ./... + + lint: + strategy: + matrix: + go-version: ["1.21"] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-go@v4 + with: + go-version: ${{ matrix.go-version }} + - run: diff -u <(echo -n) <(gofmt -s -d ./) + - run: diff -u <(echo -n) <(go vet ./...) \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index c9cdbc8..0000000 --- a/.travis.yml +++ /dev/null @@ -1,16 +0,0 @@ -language: go -arch: - - AMD64 - - ppc64le -go: - - "1.13" - - "1.14" - -before_install: - - go get -u -v golang.org/x/lint/golint - -script: - - diff -u <(echo -n) <(gofmt -s -d ./) - - diff -u <(echo -n) <(go vet ./...) - - diff -u <(echo -n) <(golint) - - go test -v -race ./... From 0f0b5cb1157c71978f240bd9c6a4c4f3f8910039 Mon Sep 17 00:00:00 2001 From: Yuji Yaginuma Date: Fri, 22 Sep 2023 10:14:31 +0900 Subject: [PATCH 2/2] Fix format --- matchers/archive.go | 32 ++++++++++++++++---------------- matchers/document.go | 2 +- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/matchers/archive.go b/matchers/archive.go index ee618a9..dd892ce 100644 --- a/matchers/archive.go +++ b/matchers/archive.go @@ -191,21 +191,21 @@ func MachO(buf []byte) bool { // There are two frame formats defined by Zstandard: Zstandard frames and Skippable frames. // See more details from https://tools.ietf.org/id/draft-kucherawy-dispatch-zstd-00.html#rfc.section.2 func Zst(buf []byte) bool { - if compareBytes(buf, zstdMagic, 0) { - return true - } else { + if compareBytes(buf, zstdMagic, 0) { + return true + } else { // skippable frames - if len(buf) < 8 { - return false - } - if binary.LittleEndian.Uint32(buf[:4]) & ZstdMagicSkippableMask == ZstdMagicSkippableStart { - userDataLength := binary.LittleEndian.Uint32(buf[4:8]) - if len(buf) < 8 + int(userDataLength) { - return false - } - nextFrame := buf[8+userDataLength:] - return Zst(nextFrame) - } - return false - } + if len(buf) < 8 { + return false + } + if binary.LittleEndian.Uint32(buf[:4])&ZstdMagicSkippableMask == ZstdMagicSkippableStart { + userDataLength := binary.LittleEndian.Uint32(buf[4:8]) + if len(buf) < 8+int(userDataLength) { + return false + } + nextFrame := buf[8+userDataLength:] + return Zst(nextFrame) + } + return false + } } diff --git a/matchers/document.go b/matchers/document.go index 5123aad..2724f00 100644 --- a/matchers/document.go +++ b/matchers/document.go @@ -44,7 +44,7 @@ const ( TYPE_ODT ) -//reference: https://bz.apache.org/ooo/show_bug.cgi?id=111457 +// reference: https://bz.apache.org/ooo/show_bug.cgi?id=111457 func Doc(buf []byte) bool { if len(buf) > 513 { return buf[0] == 0xD0 && buf[1] == 0xCF &&