From 32c454ba5faea9dc4236c12e28e0b65f01117cc1 Mon Sep 17 00:00:00 2001 From: Michael Li Date: Thu, 17 Mar 2022 14:05:09 +0800 Subject: assets: convert usage of go-bindata to Go embed (#6851) Co-authored-by: Joe Chen --- conf/embed.go | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 conf/embed.go (limited to 'conf/embed.go') 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 +} -- cgit v1.2.3