golang.org/x/tools@v0.21.0/internal/robustio/robustio_posix.go (about)

     1  // Copyright 2022 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  //go:build !windows && !plan9
     6  // +build !windows,!plan9
     7  
     8  package robustio
     9  
    10  import (
    11  	"os"
    12  	"syscall"
    13  	"time"
    14  )
    15  
    16  func getFileID(filename string) (FileID, time.Time, error) {
    17  	fi, err := os.Stat(filename)
    18  	if err != nil {
    19  		return FileID{}, time.Time{}, err
    20  	}
    21  	stat := fi.Sys().(*syscall.Stat_t)
    22  	return FileID{
    23  		device: uint64(stat.Dev), // (int32 on darwin, uint64 on linux)
    24  		inode:  stat.Ino,
    25  	}, fi.ModTime(), nil
    26  }