github.com/kevinklinger/open_terraform@v1.3.6/noninternal/configs/configload/inode.go (about)

     1  //go:build linux || darwin || openbsd || netbsd || solaris || dragonfly
     2  // +build linux darwin openbsd netbsd solaris dragonfly
     3  
     4  package configload
     5  
     6  import (
     7  	"fmt"
     8  	"os"
     9  	"syscall"
    10  )
    11  
    12  // lookup the inode of a file on posix systems
    13  func inode(path string) (uint64, error) {
    14  	stat, err := os.Stat(path)
    15  	if err != nil {
    16  		return 0, err
    17  	}
    18  	if st, ok := stat.Sys().(*syscall.Stat_t); ok {
    19  		return st.Ino, nil
    20  	}
    21  	return 0, fmt.Errorf("could not determine file inode")
    22  }