Go to file
2024-10-09 17:05:26 +08:00
.gitignore 修复推送远端时会在本地创建文件夹的问题 2024-10-09 17:05:26 +08:00
matcher.go project init 2020-04-03 20:01:47 +08:00
README.md 更新 'README.md' 2021-07-12 10:27:37 +00:00
rsync.go 修复推送远端时会在本地创建文件夹的问题 2024-10-09 17:05:26 +08:00
task.go project init 2020-04-03 20:01:47 +08:00

grsync

package main

import (
    "fmt"
    "grsync"
    "time"
)

func main() {
    task := grsync.NewTask(
        "username@server.com:/source/folder",
        "/home/user/destination",
        grsync.RsyncOptions{},
    )

    go func() {
        for {
            state := task.State()
            fmt.Printf(
                "progress: %.2f / rem. %d / tot. %d / sp. %s \n",
                state.Progress,
                state.Remain,
                state.Total,
                state.Speed,
            )
            time.Sleep(time.Second)
        }
    }()

    if err := task.Run(); err != nil {
        panic(err)
    }

    fmt.Println("well done")
    fmt.Println(task.Log())
}