daily pastebin goal
3%
SHARE
TWEET

Untitled

a guest Jun 6th, 2018 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package main
  2.  
  3. import (
  4.     "encoding/gob"
  5.     "fmt"
  6.     "os"
  7.     "bytes"
  8.     "syscall"
  9. )
  10.  
  11. type Q struct {
  12.     F os.FileInfo
  13. }
  14.  
  15. func main() {
  16.     gob.Register(&syscall.Stat_t{})
  17.     gob.Register(&os.FileStat{})
  18.  
  19.     var network bytes.Buffer
  20.     enc := gob.NewEncoder(&network)
  21.     dec := gob.NewDecoder(&network)
  22.  
  23.     f,_ := os.Lstat("/")
  24.     var q Q
  25.  
  26.     err := enc.Encode(Q{f})
  27.     if err != nil {
  28.         fmt.Errorf("%s\n", err)
  29.     }
  30.  
  31.     err = dec.Decode(&q)
  32.     if err != nil {
  33.         fmt.Errorf("%s\n", err)
  34.     }
  35.  
  36.     fmt.Println("local filestat: ", f)
  37.     fmt.Println("local Stat_t: ", f.(*os.FileStat).Sys.(*syscall.Stat_t))
  38.  
  39.     fmt.Println("remote: ", q.F)
  40.     fmt.Println("remote Stat_t: ", q.F.(*os.FileStat).Sys.(*syscall.Stat_t))
  41. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top