fix #4, use filepath.Join to create portable path's

This commit is contained in:
2023-12-18 09:21:26 +01:00
parent f932d7be83
commit 4d4577c9f8
2 changed files with 5 additions and 3 deletions

View File

@@ -21,20 +21,21 @@ import (
"io"
"log/slog"
"os"
"path/filepath"
"strings"
tpl "text/template"
)
func WriteAd(dir string, ad *Ad, template string) error {
// prepare output dir
dir = dir + "/" + ad.Slug
dir = filepath.Join(dir, ad.Slug)
err := Mkdir(dir)
if err != nil {
return err
}
// write ad file
listingfile := strings.Join([]string{dir, "Adlisting.txt"}, "/")
listingfile := filepath.Join(dir, "Adlisting.txt")
f, err := os.Create(listingfile)
if err != nil {
return err