Compare commits

...

8 Commits

Author SHA1 Message Date
Stefan Goppelt 60add201c8 NO-ISSUE: Remove code smells
continuous-integration/drone/push Build is passing Details
2025-09-14 20:31:02 +02:00
Stefan Goppelt ec9c29f52b NO-ISSUE: Check dir
continuous-integration/drone/push Build is passing Details
2025-09-14 20:22:13 +02:00
Stefan Goppelt dd6ea6b73b NO-ISSUE: drone.yml modified
continuous-integration/drone/push Build is passing Details
2025-09-14 20:14:38 +02:00
Stefan Goppelt 164cc74e8f NO-ISSUE: Fixed build
continuous-integration/drone/push Build is failing Details
2025-09-14 20:08:37 +02:00
Stefan Goppelt c2e45d54b1 NO-ISSUE: Fixed
continuous-integration/drone/push Build encountered an error Details
2025-09-14 20:05:59 +02:00
Stefan Goppelt 3621c45ab9 NO-ISSUE: A Test
continuous-integration/drone/push Build is failing Details
2025-09-14 20:01:32 +02:00
Stefan Goppelt 86f12df1c0 NO-ISSUE: Update drone
continuous-integration/drone/push Build encountered an error Details
2025-09-14 19:57:57 +02:00
Stefan Goppelt 3d154a90cb NO-ISSUE: New drone step
continuous-integration/drone/push Build is failing Details
2025-09-14 19:39:20 +02:00
6 changed files with 60 additions and 25 deletions

View File

@ -1,17 +1,46 @@
kind: pipeline kind: pipeline
type: docker type: docker
name: go-lib/util name: go-lib/util
environment:
VERSION: development
workspace:
base: /go
path: /src/scm.yoorie.de/go-lib/util
steps: steps:
- name: build - name: prepare
image: golang
commands:
- go get -v ./...
- go install gotest.tools/gotestsum@v1.13.0
- go install golang.org/x/vuln/cmd/govulncheck@latest
- name: test
image: golang image: golang
commands: commands:
- mkdir -p .build - mkdir -p .build
- go install gotest.tools/gotestsum@v1.9.0
- go get ./...
- gotestsum --format testname --junitfile .build/unittests.xml -- -coverprofile=.build/coverage.txt ./... - gotestsum --format testname --junitfile .build/unittests.xml -- -coverprofile=.build/coverage.txt ./...
- go install golang.org/x/vuln/cmd/govulncheck@latest depends_on:
- govulncheck -v ./... - prepare
- name: vulncheck
image: golang
commands:
- govulncheck ./...
- ls -la /go/
depends_on:
- prepare
- name: publish
image: golang
commands:
- echo "Publishing not implemented yet"
when:
branch:
- main
event:
- custom
trigger: trigger:
event: event:

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
.build/

13
go.mod
View File

@ -1,8 +1,15 @@
module scm.yoorie.de/go-lib/util module scm.yoorie.de/go-lib/util
go 1.16 go 1.24.0
require ( require (
github.com/stretchr/testify v1.8.2 github.com/stretchr/testify v1.11.1
golang.org/x/sys v0.6.0 golang.org/x/sys v0.36.0
)
require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
) )

23
go.sum
View File

@ -1,19 +1,18 @@
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI=
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
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/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= golang.org/x/sys v0.36.0 h1:KVRy2GtZBrk1cBYA7MKu5bEZFxQk4NIDV6RLVcC8o0k=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= golang.org/x/sys v0.36.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8=
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

View File

@ -12,7 +12,7 @@ import (
// A.K.A root, Administrator etc // A.K.A root, Administrator etc
func IsSuperUser() bool { func IsSuperUser() bool {
cuser, err := user.Current() cuser, err := user.Current()
return err == nil && "0" == cuser.Uid return err == nil && cuser.Uid == "0"
} }
// GetGlobalConfigurationDirectory returns OS specific location for putting // GetGlobalConfigurationDirectory returns OS specific location for putting

View File

@ -1,7 +1,6 @@
package util package util
import ( import (
"fmt"
"os" "os"
"os/user" "os/user"
"path/filepath" "path/filepath"
@ -67,7 +66,7 @@ func TestIsSuperUser(t *testing.T) {
func TestGlobalConfigurationDirectoryWindows(t *testing.T) { func TestGlobalConfigurationDirectoryWindows(t *testing.T) {
if runtime.GOOS != "windows" { if runtime.GOOS != "windows" {
t.Skip(fmt.Sprintf("Skipping on OS %s", runtime.GOOS)) t.Skipf("Skipping on OS %s", runtime.GOOS)
} }
appFolder := GetGlobalConfigurationDirectory("myapp") appFolder := GetGlobalConfigurationDirectory("myapp")
assert.Equal(t, filepath.Join(os.Getenv("APPDATA"), "myapp"), appFolder) assert.Equal(t, filepath.Join(os.Getenv("APPDATA"), "myapp"), appFolder)
@ -75,7 +74,7 @@ func TestGlobalConfigurationDirectoryWindows(t *testing.T) {
func TestGlobalConfigurationDirectoryLinux(t *testing.T) { func TestGlobalConfigurationDirectoryLinux(t *testing.T) {
if runtime.GOOS != "linux" { if runtime.GOOS != "linux" {
t.Skip(fmt.Sprintf("Skipping on OS %s", runtime.GOOS)) t.Skipf("Skipping on OS %s", runtime.GOOS)
} }
appFolder := GetGlobalConfigurationDirectory("myapp") appFolder := GetGlobalConfigurationDirectory("myapp")
assert.Equal(t, "/etc/myapp", appFolder) assert.Equal(t, "/etc/myapp", appFolder)
@ -83,7 +82,7 @@ func TestGlobalConfigurationDirectoryLinux(t *testing.T) {
func TestGlobalConfigurationDirectoryMacOS(t *testing.T) { func TestGlobalConfigurationDirectoryMacOS(t *testing.T) {
if runtime.GOOS != "darwin" { if runtime.GOOS != "darwin" {
t.Skip(fmt.Sprintf("Skipping on OS %s", runtime.GOOS)) t.Skipf("Skipping on OS %s", runtime.GOOS)
} }
appFolder := GetGlobalConfigurationDirectory("myapp") appFolder := GetGlobalConfigurationDirectory("myapp")
assert.Equal(t, "/etc/myapp", appFolder) assert.Equal(t, "/etc/myapp", appFolder)