Skip to content

Instantly share code, notes, and snippets.

@alwerr
Created December 5, 2024 18:25
Show Gist options
  • Save alwerr/7293162df4af71190b8abdee4b50c174 to your computer and use it in GitHub Desktop.
Save alwerr/7293162df4af71190b8abdee4b50c174 to your computer and use it in GitHub Desktop.
package main
import (
"database/sql"
"fmt"
"io"
"net/http"
_ "github.com/mattn/go-sqlite3"
)
func main() {
db, _ := sql.Open("sqlite3", "file:./database.sqlite")
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
_, e := db.Exec(`insert into posts(name)values(?)`, `alwer`)
if e != nil {
fmt.Println(e.Error())
}
io.WriteString(w, `ok`)
})
http.ListenAndServe(":8090", nil)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment