FlashCardProject is a simple Go application designed to manage flashcards. It provides functionalities to set up a database and display flashcards in a tabular format.
-
Clone the repository:
git clone https://github.com/mhoarb/FlashCardProject.git cd FlashCardProject -
Install dependencies:
go mod tidy
go buld
go installThe SetUpDatabase function in the db package sets up a MySQL database connection.
package main
import (
"fmt"
"FlashCardProject/db"
)
func main() {
db, err := db.SetUpDatabase()
if err != nil {
fmt.Println("Error setting up database:", err)
return
}
fmt.Println("Database setup successfully:", db)
}The DisplayTable function in the db package displays flashcards in a tabular format using the tablewriter package.
package main
import (
"FlashCardProject/db"
)
func main() {
flashCards := []db.FlashCard{
{Question: "What is Go?", Answer: "A programming language"},
{Question: "Who created Go?", Answer: "Google"},
}
db.DisplayTable(flashCards)
}FlashCardProject/
├── cmd/
├── db/
│ ├── db.go
│ ├── db_test.go
│ ├── flashcard.go
│ └── flashcard_test.go
├── internal/
├── go.mod
├── go.sum
└── main.go