Compare commits

...
2 Commits
Author SHA1 Message Date
Bhargav RavuriandGitHub 32af402508 Go Build Constraint: Fix Non-Linux Filename (#1494)
Correct the filename pkg/yqlib/chown_not_linux.go to escape the
default OS detection in filename format `*_GOOS[_test].go`.

Add an extra word after `linux` to resolve the issue.
pkg/yqlib/chown_not_linux_os.go

Signed-off-by: Bhargav Ravuri <vaguecoder0to.n@gmail.com>

Signed-off-by: Bhargav Ravuri <vaguecoder0to.n@gmail.com>
2023-01-02 09:43:08 +11:00
Mike Farah 285b257e0e Build constraint not working for non linux 2022-12-17 11:05:08 +11:00
3 changed files with 34 additions and 0 deletions
+18
View File
@@ -0,0 +1,18 @@
//go:build linux
package yqlib
import (
"io/fs"
"os"
"syscall"
)
func changeOwner(info fs.FileInfo, file *os.File) error {
if stat, ok := info.Sys().(*syscall.Stat_t); ok {
uid := int(stat.Uid)
gid := int(stat.Gid)
return os.Chown(file.Name(), uid, gid)
}
return nil
}
+12
View File
@@ -0,0 +1,12 @@
//go:build !linux
package yqlib
import (
"io/fs"
"os"
)
func changeOwner(info fs.FileInfo, file *os.File) error {
return nil
}
+4
View File
@@ -34,6 +34,10 @@ func (w *writeInPlaceHandlerImpl) CreateTempFile() (*os.File, error) {
if err != nil {
return nil, err
}
if err = changeOwner(info, file); err != nil {
return nil, err
}
log.Debug("WriteInPlaceHandler: writing to tempfile: %v", file.Name())
w.tempFile = file
return file, err