diff options
author | Michael Li <alimy@gility.net> | 2022-03-17 14:05:09 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-17 14:05:09 +0800 |
commit | 32c454ba5faea9dc4236c12e28e0b65f01117cc1 (patch) | |
tree | 1eea30a83f78b311983924ba3bab00884633f508 /conf/embed.go | |
parent | 39f64a1371cdb01e02aeeb04839d2689052ae1d3 (diff) |
assets: convert usage of go-bindata to Go embed (#6851)
Co-authored-by: Joe Chen <jc@unknwon.io>
Diffstat (limited to 'conf/embed.go')
-rw-r--r-- | conf/embed.go | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/conf/embed.go b/conf/embed.go new file mode 100644 index 00000000..14358cd7 --- /dev/null +++ b/conf/embed.go @@ -0,0 +1,27 @@ +// Copyright 2022 The Gogs Authors. All rights reserved. +// Use of this source code is governed by a MIT-style +// license that can be found in the LICENSE file. + +package conf + +import ( + "embed" +) + +//go:embed app.ini **/* +var Files embed.FS + +// FileNames returns a list of filenames exists in the given direction within +// Files. The list includes names of subdirectories. +func FileNames(dir string) ([]string, error) { + entries, err := Files.ReadDir(dir) + if err != nil { + return nil, err + } + + fileNames := make([]string, 0, len(entries)) + for _, entry := range entries { + fileNames = append(fileNames, entry.Name()) + } + return fileNames, nil +} |