Skip to content

Instantly share code, notes, and snippets.

@muhammadisa
Last active July 15, 2021 03:45
Show Gist options
  • Select an option

  • Save muhammadisa/a5166989fdec7c82d5703762bd443ef8 to your computer and use it in GitHub Desktop.

Select an option

Save muhammadisa/a5166989fdec7c82d5703762bd443ef8 to your computer and use it in GitHub Desktop.
func main() {
databaseUrl := fmt.Sprintf(
"%s:%s@tcp(%s:%s)/%s?parseTime=true",
"root",
"root",
"localhost",
"3306",
"example",
)
db, err := sql.Open("mysql", databaseUrl)
if err != nil {
log.Println(err)
}
repo := repository.NewRepository(db)
err = repo.WriteExample(repository.Example{
Content: "Hello World",
})
if err != nil {
log.Println(err)
}
fmt.Println(repo.ReadExamples())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment