From c921f24ce0055e75ac98aa7c41b664cdfc531c68 Mon Sep 17 00:00:00 2001 From: Max Date: Wed, 12 Oct 2022 20:31:09 +0800 Subject: [PATCH] [add] fs support & golang version 1.9.2 --- .github/workflows/pr-test.yml | 6 +-- .github/workflows/release-linux.yml | 2 +- .github/workflows/release-macos.yml | 2 +- .github/workflows/unit-test.yml | 2 +- cmd/root.go | 1 + cmd/start.go | 5 +++ config/types.go | 17 ++++---- engine/load.go | 7 ++++ fs/fs.go | 45 +++++++++++++++++++++ fs/fs_test.go | 30 ++++++++++++++ go.mod | 30 +++++++------- go.sum | 7 +++- main_test.go | 2 +- system/process.go | 61 ++++++++++++----------------- system/process_test.go | 21 ++++------ system/system.go | 2 +- xfs/process.go | 1 + xfs/process_test.go | 2 + xfs/xfs.go | 4 +- xfs/xfs_test.go | 2 + 20 files changed, 165 insertions(+), 84 deletions(-) create mode 100644 fs/fs.go create mode 100644 fs/fs_test.go diff --git a/.github/workflows/pr-test.yml b/.github/workflows/pr-test.yml index 3a4cbdd0..5ed4626a 100644 --- a/.github/workflows/pr-test.yml +++ b/.github/workflows/pr-test.yml @@ -50,7 +50,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - go: [1.18.2] + go: [1.19.2] db: [MySQL8.0, MySQL5.7, SQLite3] redis: [4, 5, 6] mongo: ["6.0"] @@ -99,7 +99,7 @@ jobs: owner: context.repo.owner, repo: context.repo.repo, issue_number: issue_number, - body: 'Thank you for the PR! The ${{ matrix.db }} test workflow is running, the results of the run will be commented later.' + body: 'Thank you for the PR! The db: ${{ matrix.db }} redis: ${{ matrix.redis }} mongo: ${{ matrix.mongo }} test workflow is running, the results of the run will be commented later.' }); - name: Setup Cache @@ -255,5 +255,5 @@ jobs: owner: context.repo.owner, repo: context.repo.repo, issue_number: issue_number, - body: '✨DONE✨ ${{ matrix.db }} passed.' + body: '✨DONE✨ db: ${{ matrix.db }} redis: ${{ matrix.redis }} mongo: ${{ matrix.mongo }} passed.' }); diff --git a/.github/workflows/release-linux.yml b/.github/workflows/release-linux.yml index 27b26651..5c29c9b2 100644 --- a/.github/workflows/release-linux.yml +++ b/.github/workflows/release-linux.yml @@ -14,7 +14,7 @@ jobs: release: strategy: matrix: - go: [1.18.2] + go: [1.19.2] runs-on: "ubuntu-latest" steps: - name: Arm Build diff --git a/.github/workflows/release-macos.yml b/.github/workflows/release-macos.yml index 3eaf009a..65a78dcd 100644 --- a/.github/workflows/release-macos.yml +++ b/.github/workflows/release-macos.yml @@ -14,7 +14,7 @@ jobs: release: strategy: matrix: - go: [1.18.2] + go: [1.19.2] runs-on: "macos-11" steps: - name: Install coscmd diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index 15a60aef..29545dec 100644 --- a/.github/workflows/unit-test.yml +++ b/.github/workflows/unit-test.yml @@ -54,7 +54,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - go: [1.18.2] + go: [1.19.2] db: [MySQL8.0, MySQL5.7, SQLite3] redis: [4, 5, 6] mongo: ["6.0"] diff --git a/cmd/root.go b/cmd/root.go index eb095106..84d63d31 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -32,6 +32,7 @@ var langs = map[string]string{ "API": " API接口", "API List": "API列表", "Root": "应用目录", + "Data": "数据目录", "Frontend": "前台地址", "Dashboard": "管理后台", "Not enough arguments": "参数错误: 缺少参数", diff --git a/cmd/start.go b/cmd/start.go index 1de96fe4..98e5d30f 100644 --- a/cmd/start.go +++ b/cmd/start.go @@ -20,6 +20,7 @@ import ( "github.com/yaoapp/kun/log" "github.com/yaoapp/yao/config" "github.com/yaoapp/yao/engine" + "github.com/yaoapp/yao/fs" "github.com/yaoapp/yao/service" "github.com/yaoapp/yao/share" ) @@ -60,6 +61,8 @@ var startCmd = &cobra.Command{ host = "127.0.0.1" } + dataRoot, _ := fs.Root(config.Conf) + fmt.Println(color.WhiteString("\n---------------------------------")) fmt.Println(color.WhiteString(share.App.Name), color.WhiteString(share.App.Version), mode) fmt.Println(color.WhiteString("---------------------------------")) @@ -71,12 +74,14 @@ var startCmd = &cobra.Command{ if share.App.XGen == "1.0" { root, _ := adminRoot() fmt.Println(color.WhiteString(L(" XGen")), color.GreenString(" 1.0")) + fmt.Println(color.WhiteString(L("Data")), color.GreenString(" %s", dataRoot)) fmt.Println(color.WhiteString(L("Frontend")), color.GreenString(" http://%s%s/", host, port)) fmt.Println(color.WhiteString(L("Dashboard")), color.GreenString(" http://%s%s%slogin/admin", host, port, root)) fmt.Println(color.WhiteString(L("API")), color.GreenString(" http://%s%s/api", host, port)) fmt.Println(color.WhiteString(L("Listening")), color.GreenString(" %s:%d", config.Conf.Host, config.Conf.Port)) } else { + fmt.Println(color.WhiteString(L("Data")), color.GreenString(" %s", dataRoot)) fmt.Println(color.WhiteString(L("Frontend")), color.GreenString(" http://%s%s/", host, port)) fmt.Println(color.WhiteString(L("Dashboard")), color.GreenString(" http://%s%s/xiang/login/admin", host, port)) fmt.Println(color.WhiteString(L("API")), color.GreenString(" http://%s%s/api", host, port)) diff --git a/config/types.go b/config/types.go index ebd3ed22..e97de955 100644 --- a/config/types.go +++ b/config/types.go @@ -2,14 +2,15 @@ package config // Config 象传应用引擎配置 type Config struct { - Mode string `json:"mode,omitempty" env:"YAO_ENV" envDefault:"production"` // 象传引擎启动模式 production/development - Root string `json:"root,omitempty" env:"YAO_ROOT" envDefault:"."` // 应用根目录 - Host string `json:"host,omitempty" env:"YAO_HOST" envDefault:"0.0.0.0"` // 服务监听地址 - Port int `json:"port,omitempty" env:"YAO_PORT" envDefault:"5099"` // 服务监听端口 - Cert string `json:"cert,omitempty" env:"YAO_CERT"` // HTTPS 证书文件地址 - Key string `json:"key,omitempty" env:"YAO_KEY"` // HTTPS 证书密钥地址 - Log string `json:"log,omitempty" env:"YAO_LOG"` // 服务日志地址 - LogMode string `json:"log_mode,omitempty" env:"YAO_LOG_MODE" envDefault:"TEXT"` // 服务日志模式 JSON|TEXT + Mode string `json:"mode,omitempty" env:"YAO_ENV" envDefault:"production"` // 象传引擎启动模式 production/development + Root string `json:"root,omitempty" env:"YAO_ROOT" envDefault:"."` // 应用根目录 + DataRoot string `json:"data_root,omitempty" env:"YAO_DATA_ROOT" envDefault:""` // DATA PATH + Host string `json:"host,omitempty" env:"YAO_HOST" envDefault:"0.0.0.0"` // 服务监听地址 + Port int `json:"port,omitempty" env:"YAO_PORT" envDefault:"5099"` // 服务监听端口 + Cert string `json:"cert,omitempty" env:"YAO_CERT"` // HTTPS 证书文件地址 + Key string `json:"key,omitempty" env:"YAO_KEY"` // HTTPS 证书密钥地址 + Log string `json:"log,omitempty" env:"YAO_LOG"` // 服务日志地址 + LogMode string `json:"log_mode,omitempty" env:"YAO_LOG_MODE" envDefault:"TEXT"` // 服务日志模式 JSON|TEXT // Session string `json:"session,omitempty" env:"YAO_SESSION" envDefault:"memory"` // 用户会话模式 memory|redis|database JWTSecret string `json:"jwt_secret,omitempty" env:"YAO_JWT_SECRET"` // JWT 密钥 DB DBConfig `json:"db,omitempty"` // 数据库配置 diff --git a/engine/load.go b/engine/load.go index 9fc757d7..ab3c2355 100644 --- a/engine/load.go +++ b/engine/load.go @@ -16,6 +16,7 @@ import ( "github.com/yaoapp/yao/config" "github.com/yaoapp/yao/connector" "github.com/yaoapp/yao/flow" + "github.com/yaoapp/yao/fs" "github.com/yaoapp/yao/importer" "github.com/yaoapp/yao/model" "github.com/yaoapp/yao/page" @@ -57,6 +58,12 @@ func Load(cfg config.Config) (err error) { printErr(cfg.Mode, "Connector", err) } + // Load FileSystem + err = fs.Load(cfg) + if err != nil { + printErr(cfg.Mode, "FileSystem", err) + } + // 第二步: 建立数据库 & 会话连接 share.DBConnect(cfg.DB) // 创建数据库连接 // share.SessionConnect(cfg.Session) // 创建会话服务器链接 diff --git a/fs/fs.go b/fs/fs.go new file mode 100644 index 00000000..30de20b9 --- /dev/null +++ b/fs/fs.go @@ -0,0 +1,45 @@ +package fs + +import ( + "os" + "path/filepath" + + "github.com/yaoapp/gou/fs" + "github.com/yaoapp/gou/fs/system" + "github.com/yaoapp/yao/config" +) + +// Load system fs +func Load(cfg config.Config) error { + + root, err := Root(cfg) + if err != nil { + return err + } + + if _, err := os.Stat(root); os.IsNotExist(err) { + err := os.MkdirAll(root, os.ModePerm) + if err != nil { + return err + } + } + + fs.Register("system", system.New(root)) + fs.Register("binary", system.New(root)) // next + return nil +} + +// Root return data root +func Root(cfg config.Config) (string, error) { + root := cfg.DataRoot + if root == "" { + root = filepath.Join(cfg.Root, "data") + } + + root, err := filepath.Abs(root) + if err != nil { + return "", err + } + + return root, nil +} diff --git a/fs/fs_test.go b/fs/fs_test.go new file mode 100644 index 00000000..cb630182 --- /dev/null +++ b/fs/fs_test.go @@ -0,0 +1,30 @@ +package fs + +import ( + "os" + "path/filepath" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/yaoapp/gou/fs" + "github.com/yaoapp/yao/config" +) + +func TestLoad(t *testing.T) { + Load(config.Conf) + + data := fs.MustGet("system") + size, err := fs.WriteFile(data, "test.file", []byte("Hi"), 0644) + assert.Nil(t, err) + assert.Equal(t, 2, size) + + root, err := Root(config.Conf) + assert.Nil(t, err) + + info, err := os.Stat(filepath.Join(root, "test.file")) + assert.Nil(t, err) + assert.Equal(t, int64(2), info.Size()) + + err = fs.Remove(data, "test.file") + assert.Nil(t, err) +} diff --git a/go.mod b/go.mod index b4040537..5c501bc0 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/yaoapp/yao -go 1.18 +go 1.19 require ( github.com/aliyun/alibaba-cloud-sdk-go v1.61.1286 @@ -23,25 +23,13 @@ require ( golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d ) -require ( - github.com/golang/snappy v0.0.1 // indirect - github.com/klauspost/compress v1.13.6 // indirect - github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe // indirect - github.com/pkg/errors v0.9.1 // indirect - github.com/xdg-go/pbkdf2 v1.0.0 // indirect - github.com/xdg-go/scram v1.1.1 // indirect - github.com/xdg-go/stringprep v1.0.3 // indirect - github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d // indirect - go.mongodb.org/mongo-driver v1.10.2 // indirect - golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect -) - require ( github.com/TylerBrock/colorjson v0.0.0-20200706003622-8a50f05110d2 // indirect github.com/blang/semver/v4 v4.0.0 // indirect github.com/cespare/xxhash/v2 v2.1.2 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect + github.com/gabriel-vasile/mimetype v1.4.1 // indirect github.com/gin-contrib/sse v0.1.0 // indirect github.com/go-errors/errors v1.4.2 // indirect github.com/go-playground/locales v0.13.0 // indirect @@ -51,6 +39,7 @@ require ( github.com/go-sql-driver/mysql v1.6.0 // indirect github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect github.com/golang/protobuf v1.5.2 // indirect + github.com/golang/snappy v0.0.1 // indirect github.com/google/uuid v1.3.0 github.com/gorilla/websocket v1.5.0 // indirect github.com/hashicorp/go-hclog v1.2.0 // indirect @@ -60,6 +49,7 @@ require ( github.com/inconshreveable/mousetrap v1.0.0 // indirect github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af // indirect github.com/jmoiron/sqlx v1.3.4 // indirect + github.com/klauspost/compress v1.13.6 // indirect github.com/leodido/go-urn v1.2.0 // indirect github.com/lib/pq v1.10.4 // indirect github.com/mattn/go-colorable v0.1.12 // indirect @@ -70,7 +60,9 @@ require ( github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect + github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe // indirect github.com/oklog/run v1.1.0 // indirect + github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/richardlehane/mscfb v1.0.3 // indirect github.com/richardlehane/msoleps v1.0.1 // indirect @@ -87,10 +79,16 @@ require ( github.com/tidwall/rtred v0.1.2 // indirect github.com/tidwall/tinyqueue v0.1.1 // indirect github.com/ugorji/go/codec v1.1.7 // indirect + github.com/xdg-go/pbkdf2 v1.0.0 // indirect + github.com/xdg-go/scram v1.1.1 // indirect + github.com/xdg-go/stringprep v1.0.3 // indirect github.com/xuri/efp v0.0.0-20210322160811-ab561f5b45e3 // indirect + github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d // indirect + go.mongodb.org/mongo-driver v1.10.2 // indirect golang.org/x/image v0.0.0-20210628002857-a66eb6448b8d // indirect golang.org/x/mod v0.4.2 // indirect - golang.org/x/net v0.0.0-20220526153639-5463443f8c37 // indirect + golang.org/x/net v0.0.0-20220624214902-1bab6f366d9e // indirect + golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a // indirect golang.org/x/text v0.3.7 // indirect golang.org/x/tools v0.1.7 // indirect @@ -101,7 +99,7 @@ require ( gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect gopkg.in/ini.v1 v1.62.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect - gopkg.in/yaml.v3 v3.0.1 + gopkg.in/yaml.v3 v3.0.1 rogchap.com/v8go v0.7.0 // indirect ) diff --git a/go.sum b/go.sum index 5e464535..6805c07b 100644 --- a/go.sum +++ b/go.sum @@ -92,6 +92,8 @@ github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYF github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= github.com/fsnotify/fsnotify v1.5.4 h1:jRbGcIw6P2Meqdwuo0H1p6JVLbL5DHKAKlYndzMwVZI= github.com/fsnotify/fsnotify v1.5.4/go.mod h1:OVB6XrOHzAwXMpEM7uPOzcehqUV2UqJxmVXmkdnm1bU= +github.com/gabriel-vasile/mimetype v1.4.1 h1:TRWk7se+TOjCYgRth7+1/OYLNiRNIotknkFtf/dnN7Q= +github.com/gabriel-vasile/mimetype v1.4.1/go.mod h1:05Vi0w3Y9c/lNvJOdmIwvrrAhX3rYhfQQCaf9VJcv7M= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= @@ -500,8 +502,8 @@ golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLd golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/net v0.0.0-20210726213435-c6fcb2dbf985/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20220526153639-5463443f8c37 h1:lUkvobShwKsOesNfWWlCS5q7fnbG1MEliIzwu886fn8= -golang.org/x/net v0.0.0-20220526153639-5463443f8c37/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= +golang.org/x/net v0.0.0-20220624214902-1bab6f366d9e h1:TsQ7F31D3bUCLeqPT0u+yjp1guoArKaNKmCr22PYgTQ= +golang.org/x/net v0.0.0-20220624214902-1bab6f366d9e/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -580,6 +582,7 @@ golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a h1:dGzPydgVsqGcTRVwiLJ1jVbufYwmzD3LfVPLKsKg+0k= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= diff --git a/main_test.go b/main_test.go index 8a00a058..5d30f841 100644 --- a/main_test.go +++ b/main_test.go @@ -31,7 +31,7 @@ func TestCommandMigrate(t *testing.T) { oldArgs := os.Args defer func() { os.Args = oldArgs }() - os.Args = append(os.Args, "migrate") + os.Args = append(os.Args, "migrate", "--reset", "--force") assert.NotPanics(t, func() { main() }) diff --git a/system/process.go b/system/process.go index 555de4e5..c1155c60 100644 --- a/system/process.go +++ b/system/process.go @@ -1,42 +1,33 @@ package system -import ( - "fmt" - "os/exec" - "strings" +// func init() { +// // gou.RegisterProcessHandler("yao.system.Exec", processExec) +// } - "github.com/yaoapp/gou" - "github.com/yaoapp/kun/exception" -) +// // processExec execute the system command +// func processExec(process *gou.Process) interface{} { +// process.ValidateArgNums(1) +// cmd := process.ArgsString(0) -func init() { - gou.RegisterProcessHandler("yao.system.Exec", processExec) -} +// _, err := exec.LookPath(cmd) +// if err != nil { +// exception.New("command %s not found: %s", 400, cmd, err.Error()).Throw() +// return nil +// } -// processExec execute the system command -func processExec(process *gou.Process) interface{} { - process.ValidateArgNums(1) - cmd := process.ArgsString(0) +// args := []string{} +// for i, arg := range process.Args { +// if i == 0 { +// continue +// } +// args = append(args, fmt.Sprintf("%v", arg)) +// } - _, err := exec.LookPath(cmd) - if err != nil { - exception.New("command %s not found: %s", 400, cmd, err.Error()).Throw() - return nil - } +// res, err := exec.Command(cmd, args...).Output() +// if err != nil { +// exception.New("command %s error: %s", 500, cmd, err.Error()).Throw() +// return nil +// } - args := []string{} - for i, arg := range process.Args { - if i == 0 { - continue - } - args = append(args, fmt.Sprintf("%v", arg)) - } - - res, err := exec.Command(cmd, args...).Output() - if err != nil { - exception.New("command %s error: %s", 500, cmd, err.Error()).Throw() - return nil - } - - return strings.TrimRight(string(res), "\n") -} +// return strings.TrimRight(string(res), "\n") +// } diff --git a/system/process_test.go b/system/process_test.go index 054fd6d0..cb0bfbe9 100644 --- a/system/process_test.go +++ b/system/process_test.go @@ -1,16 +1,9 @@ package system -import ( - "testing" - - "github.com/stretchr/testify/assert" - "github.com/yaoapp/gou" -) - -func TestProcessReturn(t *testing.T) { - output, err := gou.NewProcess("yao.system.Exec", "echo", "hello").Exec() - if err != nil { - t.Fatal(err) - } - assert.Equal(t, "hello", output) -} +// func TestProcessReturn(t *testing.T) { +// output, err := gou.NewProcess("yao.system.Exec", "echo", "hello").Exec() +// if err != nil { +// t.Fatal(err) +// } +// assert.Equal(t, "hello", output) +// } diff --git a/system/system.go b/system/system.go index 61e66e43..bfd256e1 100644 --- a/system/system.go +++ b/system/system.go @@ -1,4 +1,4 @@ package system // Exec call system command -func Exec(cmd string, args ...string) {} +// func Exec(cmd string, args ...string) {} diff --git a/xfs/process.go b/xfs/process.go index 401b67a1..a2baf54f 100644 --- a/xfs/process.go +++ b/xfs/process.go @@ -21,6 +21,7 @@ import ( "github.com/yaoapp/yao/share" ) +// DEPRECATED func init() { // 注册处理器 gou.RegisterProcessHandler("xiang.fs.Upload", processUpload) diff --git a/xfs/process_test.go b/xfs/process_test.go index 7e18f0f4..415c6cd1 100644 --- a/xfs/process_test.go +++ b/xfs/process_test.go @@ -7,6 +7,8 @@ import ( "github.com/yaoapp/yao/share" ) +// DEPRECATED + func init() { share.App = share.AppInfo{ Storage: share.AppStorage{ diff --git a/xfs/xfs.go b/xfs/xfs.go index b3dcf0f6..6dbea5b3 100644 --- a/xfs/xfs.go +++ b/xfs/xfs.go @@ -19,6 +19,8 @@ import ( "github.com/yaoapp/yao/config" ) +// DEPRECATED + // Stor 文件系统实例 var Stor Xfs @@ -209,7 +211,7 @@ func (xfs *Xfs) GetTempDir(subPath string) string { return afero.GetTempDir(xfs.Fs, subPath) } -//MustTempDir 创建临时文件夹 +// MustTempDir 创建临时文件夹 func (xfs *Xfs) MustTempDir(dirname string, prefix string) string { name, err := xfs.TempDir(dirname, prefix) if err != nil { diff --git a/xfs/xfs_test.go b/xfs/xfs_test.go index e063cc61..c21a279a 100644 --- a/xfs/xfs_test.go +++ b/xfs/xfs_test.go @@ -7,6 +7,8 @@ import ( "github.com/stretchr/testify/assert" ) +// DEPRECATED + func TestOSFsMustMkdirAll(t *testing.T) { // fs := New(config.Conf.Source) fs := New(os.Getenv("YAO_DEV"))