mirror of
https://github.com/rclone/rclone.git
synced 2024-12-23 15:38:57 +01:00
94757277bc
Before this running `go mod tidy` caused the build to break because it removed the dependency on golang.org/x/mobile and a command line tool from this package is needed for the build. This adds an explicit dependency which will mean the tool is always present.
43 lines
1.1 KiB
Go
43 lines
1.1 KiB
Go
// Package gomobile exports shims for gomobile use
|
|
package gomobile
|
|
|
|
import (
|
|
"github.com/rclone/rclone/librclone/librclone"
|
|
|
|
_ "github.com/rclone/rclone/backend/all" // import all backends
|
|
_ "github.com/rclone/rclone/lib/plugin" // import plugins
|
|
|
|
_ "golang.org/x/mobile/event/key" // make go.mod add this as a dependency
|
|
)
|
|
|
|
// RcloneInitialize initializes rclone as a library
|
|
func RcloneInitialize() {
|
|
librclone.Initialize()
|
|
}
|
|
|
|
// RcloneFinalize finalizes the library
|
|
func RcloneFinalize() {
|
|
librclone.Finalize()
|
|
}
|
|
|
|
// RcloneRPCResult is returned from RcloneRPC
|
|
//
|
|
// Output will be returned as a serialized JSON object
|
|
// Status is a HTTP status return (200=OK anything else fail)
|
|
type RcloneRPCResult struct {
|
|
Output string
|
|
Status int
|
|
}
|
|
|
|
// RcloneRPC has an interface optimised for gomobile, in particular
|
|
// the function signature is valid under gobind rules.
|
|
//
|
|
// https://pkg.go.dev/golang.org/x/mobile/cmd/gobind#hdr-Type_restrictions
|
|
func RcloneRPC(method string, input string) (result *RcloneRPCResult) { //nolint:deadcode
|
|
output, status := librclone.RPC(method, input)
|
|
return &RcloneRPCResult{
|
|
Output: output,
|
|
Status: status,
|
|
}
|
|
}
|