Shares a file or text with other applications on the device.
Usage #
package main
import (
"fmt"
t "github.com/hugmouse/gotermux"
)
func main() {
// Share text with send action
shareConfig := t.TShare{
Action: t.TShareSend,
Title: "Check this out!",
Default: false,
}
result := t.TermuxShare(shareConfig)
fmt.Println("Share result:", result)
}
Parameters #
t TShare
- Share configuration structure
Struct TShare #
Field | Type | Description |
---|---|---|
Action | ShareAction | Share action type |
Title | string | Title for the share dialog |
Default | bool | Use default handler without showing dialog |
ShareAction Constants #
TShareView
- Open content for viewingTShareEdit
- Open content for editingTShareSend
- Send/share content with other apps
Return Value #
Returns string
containing the result of the share operation.
Examples #
Share with View Action #
shareConfig := t.TShare{
Action: t.TShareView,
Title: "View Document",
}
t.TermuxShare(shareConfig)
Share with Default Handler #
shareConfig := t.TShare{
Action: t.TShareSend,
Default: true, // Skip app chooser dialog
}
t.TermuxShare(shareConfig)
This function can share files specified as arguments or text received on stdin. The specific content to share depends on how you invoke the underlying termux-share command.