Created
December 5, 2024 18:25
-
-
Save alwerr/7293162df4af71190b8abdee4b50c174 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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