boyter / lc

licensechecker (lc) a command line application which scans directories and identifies what software license things are under producing reports as either SPDX, CSV, JSON, XLSX or CLI Tabular output. Dual-licensed under MIT or the UNLICENSE.
GNU Affero General Public License v3.0
124 stars 17 forks source link

build fails on 32-bit platforms #9

Closed ebfe closed 6 years ago

ebfe commented 6 years ago
$ GOARCH=386 go build
# github.com/boyter/lc/parsers
parsers/helpers.go:94:13: constant 1099511627776 overflows int

$ GOARCH=arm go build
# github.com/boyter/lc/parsers
parsers/helpers.go:94:13: constant 1099511627776 overflows int
ebfe commented 6 years ago
diff --git parsers/guesser.go parsers/guesser.go
index 1f55738..eeac0fa 100644
--- parsers/guesser.go
+++ parsers/guesser.go
@@ -299,7 +299,7 @@ func processFile(directory string, file string, rootLicenses []LicenseMatch) Fil
                Md5Hash:           getMd5Hash(content),
                Sha1Hash:          getSha1Hash(content),
                Sha256Hash:        getSha256Hash(content),
-               BytesHuman:        bytesToHuman(len(content)),
+               BytesHuman:        bytesToHuman(int64(len(content))),
                Bytes:             len(content)}

        return fileResult
diff --git parsers/helpers.go parsers/helpers.go
--- parsers/helpers.go
+++ parsers/helpers.go
@@ -80,9 +80,9 @@ func licenceListHasLicense(license LicenseMatch, licenseList []LicenseMatch) boo
 // Apache-2.0 is compatible with GPL-3.0-only
 // See https://apache.org/licenses/GPL-compatibility.html
 // SPDX-License-Identifier: Apache-2.0
-func bytesToHuman(bytes int) string {
+func bytesToHuman(bytes int64) string {

        const TERABYTE = 1099511627776
        const GIGABYTE = 1073741824
        const MEGABYTE = 1048576
        const KILOBYTE = 1024

seems to fix this.

boyter commented 6 years ago

Oh neat. That's a good pickup. Ill implement that now.

boyter commented 6 years ago

Merged in. Should be all good. Thanks for reporting it.

ebfe commented 6 years ago

Btw. any reason you use dos line endings? This makes it a bit difficult to work on the source tree with typical go editor setup (e.g. running go fmt on save etc.).

boyter commented 6 years ago

None other than I recently moved from a Mac to a Windows machine and am still in the transition period. Ill update my editor to use unix line endings.

boyter commented 6 years ago

https://github.com/boyter/lc/commit/2ec3dc352105bc045e56754d57ec20dd007d1048

Should resolve that.

boyter commented 6 years ago

Final one for this 62221109517c3cb8ae3cce1d42e81b0f1d8b408e added multiple targets to travis to ensure it builds on everything.