made cross-platform development easier

Signed-off-by: ari melody <ari@arimelody.me>
This commit is contained in:
ari melody 2024-03-20 07:14:05 +00:00
parent 4b5e6a50ff
commit 9d56ca63af
5 changed files with 85 additions and 22 deletions

46
.air.toml Normal file
View file

@ -0,0 +1,46 @@
root = "."
testdata_dir = "testdata"
tmp_dir = "tmp"
[build]
args_bin = []
bin = "./tmp/main"
cmd = "go build -o ./tmp/main ."
delay = 1000
exclude_dir = ["assets", "tmp", "vendor", "testdata"]
exclude_file = []
exclude_regex = ["_test.go"]
exclude_unchanged = false
follow_symlink = false
full_bin = ""
include_dir = []
include_ext = ["go", "tpl", "tmpl", "html"]
include_file = []
kill_delay = "0s"
log = "build-errors.log"
poll = false
poll_interval = 0
post_cmd = []
pre_cmd = []
rerun = false
rerun_delay = 500
send_interrupt = false
stop_on_error = false
[color]
app = ""
build = "yellow"
main = "magenta"
runner = "green"
watcher = "cyan"
[log]
main_only = false
time = false
[misc]
clean_on_exit = false
[screen]
clear_on_rebuild = false
keep_scroll = true

3
.gitignore vendored
View file

@ -1,3 +1,2 @@
**/.DS_Store
**/*.ps1
**/*.sh
tmp/

2
db.go
View file

@ -80,7 +80,7 @@ func PushAlbum(db *sqlx.DB, album music.Album) {
}
func InitDatabase() *sqlx.DB {
db, err := sqlx.Connect("postgres", "user=arimimi dbname=arimelody password=fuckingpassword sslmode=disable")
db, err := sqlx.Connect("postgres", "user=arimelody dbname=arimelody password=fuckingpassword sslmode=disable")
if err != nil {
fmt.Fprintf(os.Stderr, "unable to create database connection pool: %v\n", err)
os.Exit(1)

18
docker-compose-db.yml Normal file
View file

@ -0,0 +1,18 @@
version: '3.9'
services:
db:
image: postgres:16.1-alpine3.18
container_name: arimelody.me-db
ports:
- 5432:5432
volumes:
- arimelody-db:/var/lib/postgresql/data
environment:
POSTGRES_DB: arimelody
POSTGRES_USER: arimelody
POSTGRES_PASSWORD: fuckingpassword
volumes:
arimelody-db:
external: true

14
main.go
View file

@ -1,16 +1,16 @@
package main
import (
"arimelody.me/arimelody.me/api/v1/music"
"fmt"
"html/template"
"os"
"net/http"
"log"
"net/http"
"os"
"strconv"
"strings"
"time"
"strconv"
"arimelody.me/arimelody.me/api/v1/music"
"github.com/gomarkdown/markdown"
"github.com/gomarkdown/markdown/html"
@ -155,7 +155,7 @@ func static_handler(writer http.ResponseWriter, req *http.Request) int {
}
// setting MIME types
filetype := filename[strings.LastIndex(filename, ".") + 1:]
filetype := filename[strings.LastIndex(filename, ".")+1:]
if mime_type, ok := mime_types[filetype]; ok {
writer.Header().Set("Content-Type", mime_type)
} else {
@ -172,7 +172,7 @@ func parse_markdown(md []byte) []byte {
doc := p.Parse(md)
htmlFlags := html.CommonFlags
opts := html.RendererOptions{ Flags: htmlFlags }
opts := html.RendererOptions{Flags: htmlFlags}
renderer := html.NewRenderer(opts)
return markdown.Render(doc, renderer)