github.com/koko1123/flow-go-1@v0.29.6/utils/io/file_unix.go (about)

     1  //go:build !windows
     2  
     3  package io
     4  
     5  import (
     6  	"fmt"
     7  	"io/fs"
     8  	"os"
     9  	"syscall"
    10  )
    11  
    12  func chown(path string, fileInfo fs.FileInfo) error {
    13  	stat, ok := fileInfo.Sys().(*syscall.Stat_t)
    14  	if !ok {
    15  		return fmt.Errorf("failed to get raw syscall.Stat_t data for '%s'", path)
    16  	}
    17  
    18  	return os.Lchown(path, int(stat.Uid), int(stat.Gid))
    19  }