Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support golangci-linter #257

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Set up Go
uses: actions/setup-go@v2
uses: actions/setup-go@v3
with:
go-version: 1.18
go-version: '^1.20.x'
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since it's already required in go.mod

- uses: actions/cache@v2
with:
path: |
Expand Down
26 changes: 26 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
on:
workflow_dispatch:
push:
branches:
- 'master'
paths-ignore:
- '.idea/..'
- 'docs/**'
pull_request:
paths-ignore:
- '.idea/..'
- 'docs/**'

name: lint
jobs:
golangci:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: '^1.20.x'
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.53.2
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
!*.md
!*.iml
!*.xml
!*.yml
!*.yaml

# Don't ignore Github Actions
!.github/workflows/*
Expand Down
26 changes: 26 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
run:
timeout: 10m
linters:
enable:
- megacheck
- govet
- errcheck
- staticcheck
- unused
- gosimple
- ineffassign
- typecheck
- bodyclose
- rowserrcheck
- asciicheck
- misspell
- prealloc
- exportloopref
- promlinter
- unconvert
- dupl
- goconst
- unused
disable:
- gosec
- lll
8 changes: 8 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/golangci/golangci-lint
rev: v1.53.2
hooks:
- id: golangci-lint
entry: golangci-lint run --fix
4 changes: 1 addition & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ require (
github.com/fsnotify/fsnotify v1.6.0
github.com/godbus/dbus/v5 v5.1.0
github.com/google/go-github v17.0.0+incompatible
github.com/grandcat/zeroconf v1.0.0
github.com/h2non/go-is-svg v0.0.0-20160927212452-35e8c4b0612c
github.com/hashicorp/go-version v1.6.0
github.com/mgord9518/imgconv v0.0.0-20211227113402-4a8e0ad15713
Expand All @@ -35,7 +34,6 @@ require (

require (
github.com/CalebQ42/fuse v0.1.0 // indirect
github.com/cenkalti/backoff v2.2.1+incompatible // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
github.com/emirpasic/gods v1.12.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.1 // indirect
Expand All @@ -45,9 +43,9 @@ require (
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
github.com/kevinburke/ssh_config v0.0.0-20190725054713-01f96b0aa0cd // indirect
github.com/klauspost/compress v1.15.12 // indirect
github.com/miekg/dns v1.1.27 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/pierrec/lz4/v4 v4.1.17 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/rasky/go-lzo v0.0.0-20200203143853-96a758eda86e // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/rustyoz/Mtransform v0.0.0-20190224104252-60c8c35a3681 // indirect
Expand Down
13 changes: 0 additions & 13 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239 h1:kFOfPq6dUM1hTo
github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c=
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio=
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs=
github.com/cenkalti/backoff v2.2.1+incompatible h1:tNowT99t7UNflLxfYYSlKYsBpXdEet03Pg2g16Swow4=
github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM=
github.com/cheekybits/is v0.0.0-20150225183255-68e9c0620927 h1:SKI1/fuSdodxmNNyVBR8d7X/HuLnRpvvFO0AgyQk764=
github.com/cheekybits/is v0.0.0-20150225183255-68e9c0620927/go.mod h1:h/aW8ynjgkuj+NQRlZcDbAbM1ORAbXjXX77sX7T289U=
github.com/coreos/go-systemd/v22 v22.4.0 h1:y9YHcjnjynCd/DVbg5j9L/33jQM3MxJlbj/zWskzfGU=
Expand Down Expand Up @@ -54,8 +52,6 @@ github.com/google/go-querystring v0.0.0-20170111101155-53e6ce116135 h1:zLTLjkaOF
github.com/google/go-querystring v0.0.0-20170111101155-53e6ce116135/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck=
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/grandcat/zeroconf v1.0.0 h1:uHhahLBKqwWBV6WZUDAT71044vwOTL+McW0mBJvo6kE=
github.com/grandcat/zeroconf v1.0.0/go.mod h1:lTKmG1zh86XyCoUeIHSA4FJMBwCJiQmGfcP2PdzytEs=
github.com/h2non/go-is-svg v0.0.0-20160927212452-35e8c4b0612c h1:fEE5/5VNnYUoBOj2I9TP8Jc+a7lge3QWn9DKE7NCwfc=
github.com/h2non/go-is-svg v0.0.0-20160927212452-35e8c4b0612c/go.mod h1:ObS/W+h8RYb1Y7fYivughjxojTmIu5iAIjSrSLCLeqE=
github.com/hashicorp/go-version v1.6.0 h1:feTTfFNnjP967rlCxM/I9g701jU+RN74YKx2mOkIeek=
Expand All @@ -75,8 +71,6 @@ github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/mgord9518/imgconv v0.0.0-20211227113402-4a8e0ad15713 h1:XdqgGtorrKq4AgEHVA6H5zYGKWInTMQd69JE4QW9/74=
github.com/mgord9518/imgconv v0.0.0-20211227113402-4a8e0ad15713/go.mod h1:nxoRYGVQZklb0OuygCr8Xq4iEYz11MKmG7TaTAQ/3fM=
github.com/miekg/dns v1.1.27 h1:aEH/kqUzUxGJ/UHcEKdJY+ugH6WEzsEBBSPa8zuy1aM=
github.com/miekg/dns v1.1.27/go.mod h1:KNUDUusw/aVsxyTYZM1oqvCicbwhgbNgztCETuNZ7xM=
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
github.com/otiai10/copy v1.7.0 h1:hVoPiN+t+7d2nzzwMiDHPSOogsWAStewq3TwU05+clE=
Expand Down Expand Up @@ -153,19 +147,15 @@ go.lsp.dev/uri v0.3.0/go.mod h1:P5sbO1IQR+qySTWOCnhnK7phBx+W3zbLqSMDJNTw88I=
golang.org/x/crypto v0.0.0-20190219172222-a4c6cb3142f2/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.0.0-20221005025214-4161e89ecf1b h1:huxqepDufQpLLIRXiVkTvnxrzJlpwmIWAObmcCcUFr0=
golang.org/x/crypto v0.0.0-20221005025214-4161e89ecf1b/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/image v0.5.0 h1:5JMiNunQeQw++mMOz48/ISeNu3Iweh/JaZU8ZLqHRrI=
golang.org/x/image v0.5.0/go.mod h1:FVC7BI/5Ym8R25iw5OLsgshdUBbT1h5jZTpA+mvAdZ4=
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200425230154-ff2c4b7c35a0/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20220624214902-1bab6f366d9e/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
Expand All @@ -181,7 +171,6 @@ golang.org/x/sys v0.0.0-20190221075227-b4e8571b14e0/go.mod h1:STP8DvDyc/dI5b8T5h
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190924154521-2837fb4f24fe/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
Expand All @@ -204,10 +193,8 @@ golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190729092621-ff9f1409240a/go.mod h1:jcCCGcm9btYwXyDqrUWc6MKQKKGJCWEQ3AfLSRIbEuI=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20191216052735-49a3e744a425/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
Expand Down
25 changes: 15 additions & 10 deletions internal/helpers/appdir.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func NewAppDir(desktopFilePath string) (AppDir, error) {
var ad AppDir

// Check if desktop file exists
if Exists(desktopFilePath) == false {
if !Exists(desktopFilePath) {
return ad, errors.New("Desktop file not found")
}
ad.DesktopFilePath = desktopFilePath
Expand Down Expand Up @@ -54,7 +54,7 @@ func NewAppDir(desktopFilePath string) (AppDir, error) {
if err != nil {
log.Printf("%v\n", err)
}
if strings.HasSuffix(info.Name(), ".desktop") == true {
if strings.HasSuffix(info.Name(), ".desktop") {
ad.DesktopFilePath = ad.Path + "/" + info.Name()
counter = counter + 1
}
Expand All @@ -80,7 +80,7 @@ func NewAppDir(desktopFilePath string) (AppDir, error) {
return ad, err
}

if sect.HasKey("Exec") == false {
if !sect.HasKey("Exec") {
err = errors.New("'Desktop Entry' section has no Exec= key")
return ad, err
}
Expand Down Expand Up @@ -147,27 +147,32 @@ func (appdir AppDir) CreateIconDirectories() error {
// Only use the most common sizes in the hope that at least
// those will work on all target systems
iconSizes := []int{512, 256, 128, 48, 32, 24, 22, 16, 8}
var err error = nil
var errs []error
for _, iconSize := range iconSizes {
err = os.MkdirAll(appdir.Path+"/usr/share/icons/hicolor/"+string(iconSize)+"x"+string(iconSize)+"/apps", 0755)
err := os.MkdirAll(fmt.Sprintf("%s/usr/share/icons/hicolor/%dx%d/apps", appdir.Path, iconSize, iconSize), 0755)
if err != nil {
errs = append(errs, err)
}
}
return err
return errors.Join(errs...)
}

// CopyMainIconToRoot copies the most suitable icon for the
// Icon= entry in DesktopFilePath to the root of the AppDir
func (appdir AppDir) CopyMainIconToRoot(iconName string) error {
var err error = nil
var errs []error
iconPreferenceOrder := []int{128, 256, 512, 48, 32, 24, 22, 16, 8}
if Exists(appdir.Path + "/" + iconName + ".png") {
log.Println("Top-level icon already exists, leaving untouched")
} else {
for _, iconSize := range iconPreferenceOrder {
candidate := appdir.Path + "/usr/share/icons/hicolor/" + string(iconSize) + "x" + string(iconSize) + "/apps/" + iconName + ".png"
candidate := fmt.Sprintf("%s/usr/share/icons/hicolor/%dx%d/apps/%s.png", appdir.Path, iconSize, iconSize, iconName)
if Exists(candidate) {
CopyFile(candidate, appdir.Path+"/"+iconName+".png")
if err := CopyFile(candidate, appdir.Path+"/"+iconName+".png"); err != nil {
errs = append(errs, err)
}
}
}
}
return err
return errors.Join(errs...)
}
2 changes: 1 addition & 1 deletion internal/helpers/desktopfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func CheckDesktopFile(desktopfile string) error {
PrintError("ini.load", err)
neededKeys := []string{"Categories", "Name", "Exec", "Type", "Icon"}
for _, k := range neededKeys {
if d.Section("Desktop Entry").HasKey(k) == false {
if !d.Section("Desktop Entry").HasKey(k) {
return errors.New(".desktop file is missing a '" + k + "'= key\n")
}
}
Expand Down
2 changes: 1 addition & 1 deletion internal/helpers/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func TestGit() {

var r *git.Repository
var err error
if s.IsDir() == false {
if !s.IsDir() {
r, err = git.PlainClone(dir, false, &git.CloneOptions{
URL: "https://github.com/src-d/go-git",
Progress: os.Stdout,
Expand Down
16 changes: 5 additions & 11 deletions internal/helpers/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,7 @@ func CheckIfFolderExists(filepath string) bool {
// Returns true if it does, false otherwise.
func CheckIfFileOrFolderExists(filepath string) bool {
_, err := os.Stat(filepath)
if os.IsNotExist(err) {
return false
}
return true
return !os.IsNotExist(err)
}

// CheckIfExecFileExists checks whether a desktop file
Expand Down Expand Up @@ -219,7 +216,7 @@ func DeleteDesktopFilesWithNonExistingTargets() {
for _, file := range files {
if strings.HasSuffix(file.Name(), ".desktop") && strings.HasPrefix(file.Name(), "appimagekit_") {
exists := CheckIfExecFileExists(xdg.DataHome + "/applications/" + file.Name())
if exists == false {
if exists {
log.Println("Deleting", xdg.DataHome+"/applications/"+file.Name())
e = os.Remove(xdg.DataHome + "/applications/" + file.Name())
LogError("desktop", e)
Expand All @@ -241,7 +238,7 @@ func GetValuesForAllDesktopFiles(key string) []string {
for _, file := range files {
if strings.HasSuffix(file.Name(), ".desktop") {
exists := CheckIfExecFileExists(xdg.DataHome + "/applications/" + file.Name())
if exists == true {
if exists {
cfg, e := ini.LoadSources(ini.LoadOptions{IgnoreInlineComment: true}, // Do not cripple lines hat contain ";"
xdg.DataHome+"/applications/"+file.Name())
LogError("GetValuesForAllDesktopFiles", e)
Expand Down Expand Up @@ -328,7 +325,7 @@ func CheckIfSquashfsVersionSufficient(toolname string) bool {
cmd := exec.Command(toolname, "-version")
out, err := cmd.CombinedOutput()
// Interestingly unsquashfs 4.4 does not return with 0, unlike mksquashfs 4.3
if strings.Contains(string(out), "version") == false {
if !strings.Contains(string(out), "version") {
PrintError(toolname, err)
fmt.Printf("%s", string(out))
return false
Expand Down Expand Up @@ -549,10 +546,7 @@ func CheckForNeededTools(tools []string) error {
// IsCommandAvailable returns true if a file is on the $PATH
func IsCommandAvailable(name string) bool {
_, err := exec.LookPath(name)
if err == nil {
return true
}
return false
return err == nil
}

// SliceContains returns true if the []string contains string,
Expand Down
12 changes: 8 additions & 4 deletions internal/helpers/opgp.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ package helpers
import (
"bytes"
"encoding/base64"
"errors"
"fmt"
"log"
"strings"
Expand Down Expand Up @@ -96,19 +95,24 @@ func createKeyPair() {
// based on https://stackoverflow.com/a/34008326
func CheckSignature(path string) (*openpgp.Entity, error) {
var ent *openpgp.Entity
err := errors.New("could not verify AppImage signature") // Be pessimistic by default, unless we can positively verify the signature
pubkeybytes, err := GetSectionData(path, ".sig_key")
if err != nil {
return nil, err
}

keyring, err := openpgp.ReadArmoredKeyRing(bytes.NewReader(pubkeybytes))
if err != nil {
return ent, err
return nil, err
}

sigbytes, err := GetSectionData(path, ".sha256_sig")
if err != nil {
return nil, err
}

ent, err = openpgp.CheckArmoredDetachedSignature(keyring, strings.NewReader(CalculateSHA256Digest(path)), bytes.NewReader(sigbytes))
if err != nil {
return ent, err
return nil, err
}

return ent, nil
Expand Down
8 changes: 2 additions & 6 deletions internal/helpers/updateinformation.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,17 +114,13 @@ func ValidateUpdateInformation(updateinformation string) error {
if detectedTm == "zsync" && u.Scheme == "" { // FIXME: This apparently never triggers, why?
return errors.New("Scheme is missing, zsync needs e.,g,. http:// or https://")
}
if strings.HasSuffix(u.Path, ".zsync") == false {
if !strings.HasSuffix(u.Path, ".zsync") {
return errors.New(updateinformation + " does not end in .zsync")
}

return nil
}

func getChangelogHeadlineForUpdateInformation(updateinformation string) string {
return ""
}

// Taken and modified from
// <https://github.com/AppImageCrafters/appimage-update/blob/945dfa16017496be7a3f21c827a7ffb11124e548/util/util.go>
func ReadUpdateInfo(appImagePath string) (string, error) {
Expand All @@ -137,7 +133,7 @@ func ReadUpdateInfo(appImagePath string) (string, error) {
if updInfoSect == nil {
return "", errors.New("ELF missing .upd_info section")
}

sectionData, err := updInfoSect.Data()
if err != nil {
return "", errors.New("unable to read update information from section")
Expand Down
Loading