Moved around more code. Implemented more sqlc. Added support to generate swagger.
Added support for profiling. Removed the pkg module altogether. Everything except old sync is now using code generated by sqlc.
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
package backend
|
||||
|
||||
import (
|
||||
"log"
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func GetCharacters() []string {
|
||||
musicPath := os.Getenv("MUSIC_PATH")
|
||||
charactersPath := musicPath + "characters/"
|
||||
files, err := os.ReadDir(charactersPath)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
var characters []string
|
||||
for _, file := range files {
|
||||
if isImage(file) {
|
||||
characters = append(characters, file.Name())
|
||||
}
|
||||
}
|
||||
return characters
|
||||
}
|
||||
|
||||
func GetCharacter(character string) string {
|
||||
musicPath := os.Getenv("MUSIC_PATH")
|
||||
charactersPath := musicPath + "characters/"
|
||||
return charactersPath + character
|
||||
}
|
||||
|
||||
func isImage(entry os.DirEntry) bool {
|
||||
return !entry.IsDir() && (strings.HasSuffix(entry.Name(), ".jpg") || strings.HasSuffix(entry.Name(), ".png"))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user