generated from pluveto/go-cli-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: improve package archive level * feat: support yaml config
- Loading branch information
Showing
4 changed files
with
109 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
server: | ||
host: 0.0.0.0 | ||
port: 7086 | ||
path: /webdav | ||
fs_dir: /tmp/flydav | ||
ui: | ||
enabled: false | ||
path: /ui | ||
source: /usr/share/flydav/ui | ||
auth: {} | ||
log: | ||
level: Warning | ||
file: | ||
- format: json | ||
path: /var/log/flydav.log | ||
max_size: 1 | ||
max_age: 28 | ||
stdout: | ||
- format: text | ||
output: stdout | ||
cors: | ||
enabled: true | ||
allowed_origins: | ||
- '*' | ||
allowed_methods: | ||
- GET | ||
- POST | ||
- PUT | ||
- DELETE | ||
- PROPFIND | ||
- PROPPATCH | ||
- MKCOL | ||
- COPY | ||
- MOVE | ||
- LOCK | ||
- UNLOCK | ||
- OPTIONS | ||
- HEAD | ||
- PATCH | ||
allowed_headers: | ||
- '*' | ||
exposed_headers: | ||
- '*' | ||
allow_credentials: true | ||
max_age: 86400 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package misc | ||
|
||
import ( | ||
"fmt" | ||
"path/filepath" | ||
"strings" | ||
) | ||
|
||
func MustGetFileExt(path string) (string, error) { | ||
ext := filepath.Ext(path) | ||
if ext == "" || ext == "." { | ||
return "", fmt.Errorf("invalid file path " + path) | ||
} | ||
return strings.TrimPrefix(ext, "."), nil | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package misc | ||
|
||
import "testing" | ||
func TestMustGetFileExt(t *testing.T) { | ||
tests := []struct { | ||
path string | ||
expected string | ||
err bool | ||
}{ | ||
{"file.txt", "txt", false}, | ||
{"path/to/file.jpg", "jpg", false}, | ||
{"no_extension", "", true}, | ||
{"", "", true}, | ||
} | ||
|
||
for _, test := range tests { | ||
ext, err := MustGetFileExt(test.path) | ||
if test.err && err == nil { | ||
t.Errorf("Expected error for path %s, but got nil", test.path) | ||
} else if !test.err && err != nil { | ||
t.Errorf("Unexpected error for path %s: %v", test.path, err) | ||
} | ||
if ext != test.expected { | ||
t.Errorf("Expected extension %s for path %s, but got %s", test.expected, test.path, ext) | ||
} | ||
} | ||
} |