securestore
import "github.com/tangoui/tango/sys/securestore"本页由
site/tools/apigen从源码注释生成(按 darwin 构建标签选文件),请勿手改。
Package securestore keeps small secrets (tokens, keys, passwords) in the platform's protected storage: the Keychain on iOS and macOS (generic passwords of the app, this device only, available after first unlock); on Android values encrypted with an AES key held in the Android Keystore, stored in the app's private SharedPreferences; the Credential Manager on Windows (generic credentials of the user, not roaming); and the Secret Service on Linux (GNOME Keyring, KWallet) through libsecret. Linux returns ErrUnsupported when libsecret-1 is not installed or no Secret Service is running (headless sessions).
securestore.SetString(a, "session", tok)
tok, err := securestore.GetString(a, "session") // ErrNotFound if never set
Items survive app updates; on iOS Keychain items may survive uninstalling the app. Values are meant to be small (kilobytes). Calls are safe from any goroutine and do not need the main thread. They return ErrUnsupported where the backend has no secure store.
变量
var (
ErrUnsupported = platform.ErrUnsupported
ErrNotFound = platform.ErrNotFound
)函数
func Delete
func Delete(a *tango.App, key string) errorDelete removes key; deleting a missing key is not an error.
func Get
func Get(a *tango.App, key string) ([]byte, error)Get returns the value stored under key, or ErrNotFound.
func GetString
func GetString(a *tango.App, key string) (string, error)GetString is Get for text.
func Set
func Set(a *tango.App, key string, value []byte) errorSet stores value under key, replacing any previous value.
func SetString
func SetString(a *tango.App, key, value string) errorSetString is Set for text.