mirror of
https://github.com/mikefarah/yq.git
synced 2026-09-07 02:48:27 +08:00
Build constraint not working for non linux
This commit is contained in:
@@ -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
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
//go:build !linux
|
||||||
|
|
||||||
|
package yqlib
|
||||||
|
|
||||||
|
import (
|
||||||
|
"io/fs"
|
||||||
|
"os"
|
||||||
|
)
|
||||||
|
|
||||||
|
func changeOwner(info fs.FileInfo, file *os.File) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
@@ -34,6 +34,10 @@ func (w *writeInPlaceHandlerImpl) CreateTempFile() (*os.File, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err = changeOwner(info, file); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
log.Debug("WriteInPlaceHandler: writing to tempfile: %v", file.Name())
|
log.Debug("WriteInPlaceHandler: writing to tempfile: %v", file.Name())
|
||||||
w.tempFile = file
|
w.tempFile = file
|
||||||
return file, err
|
return file, err
|
||||||
|
|||||||
Reference in New Issue
Block a user