Skip to content

paths ​

go
import "github.com/tangoui/tango/service/paths"

本页由 site/tools/apigen 从源码注释生成(按 darwin 构建标签选文件),请勿手改。

Package paths returns the per-user directories an application keeps its files in, on every platform Tango runs on.

On desktop each directory is the platform's conventional location with the app ID appended; the app ID should be a reverse-DNS name such as "com.example.notes". Mobile apps are sandboxed, so there the ID is not appended.

           Config                     Data                        Cache                    Logs
macOS      ~/Library/Application      ~/Library/Application       ~/Library/Caches/ID      ~/Library/Logs/ID
           Support/ID                 Support/ID
Windows    %AppData%\ID               %LocalAppData%\ID           %LocalAppData%\ID\Cache  %LocalAppData%\ID\Logs
Linux/BSD  $XDG_CONFIG_HOME/ID        $XDG_DATA_HOME/ID           $XDG_CACHE_HOME/ID       $XDG_STATE_HOME/ID/logs
iOS        $HOME/Library/Application  $HOME/Library/Application   $HOME/Library/Caches     $HOME/Library/Caches/Logs
           Support                    Support/Data
Android    $HOME/config               $HOME/data                  $HOME/cache              $HOME/logs

The functions only compute paths; call os.MkdirAll before use.

函数 ​

func Cache ​

go
func Cache(appID string) (string, error)

Cache returns For(appID).Cache.

func Config ​

go
func Config(appID string) (string, error)

Config returns For(appID).Config.

func Data ​

go
func Data(appID string) (string, error)

Data returns For(appID).Data.

func Logs ​

go
func Logs(appID string) (string, error)

Logs returns For(appID).Logs.

类型 ​

Dirs ​

go
type Dirs struct {
	Config string // settings the user would miss if lost
	Data   string // documents, databases and other durable state
	Cache  string // files that can be recreated; the OS may delete them
	Logs   string // log files
}

Dirs are an application's directories.

func For ​

go
func For(appID string) (Dirs, error)

For returns the directories of the app with the given ID on this platform.

以 MIT 许可发布