Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import (
- "encoding/gob"
- "fmt"
- "os"
- "bytes"
- "syscall"
- )
- type Q struct {
- F os.FileInfo
- }
- func main() {
- gob.Register(&syscall.Stat_t{})
- gob.Register(&os.FileStat{})
- var network bytes.Buffer
- enc := gob.NewEncoder(&network)
- dec := gob.NewDecoder(&network)
- f,_ := os.Lstat("/")
- var q Q
- err := enc.Encode(Q{f})
- if err != nil {
- fmt.Errorf("%s\n", err)
- }
- err = dec.Decode(&q)
- if err != nil {
- fmt.Errorf("%s\n", err)
- }
- fmt.Println("local filestat: ", f)
- fmt.Println("local Stat_t: ", f.(*os.FileStat).Sys.(*syscall.Stat_t))
- fmt.Println("remote: ", q.F)
- fmt.Println("remote Stat_t: ", q.F.(*os.FileStat).Sys.(*syscall.Stat_t))
- }
Add Comment
Please, Sign In to add comment