![]() Opt) error )Īnd add the parameter to our function func handleFunc (opts wmenu. Let's create a main.go that looks like this: package main Install the WMenu package: go get /dixonwille /wmenu We won't focus too heavily on the menu system itself because the intent of this article is to show you how to utilize SQLite.įirst, we'll create a Go module and work with main.go to start. We'll use this menu and a scanner to accept input to interact with our database. I'm going to use The WMenu package from Dixonwille for this, so we have an interface for our data. We will build a CLI application that accesses a SQLite database. So let's get started! Creating the menu system We'll start by creating a menu, then building out methods for each operation, and in the end, you'll have an application that looks like this: It has a database full of people with their first name, last name, email address, and IP address. I'll start with pre-populated database you can download here. You can follow along and build this application or use this as a reference to build something of your own. We'll build a CLI (command-line interface) application with Go and SQLite. So we're going to combine these two technologies to show you how easy it is to marry the two. It's ubiquitous in mobile phones and devices, and SQLite powers many websites today. In fact, you're likely already using SQLite every day and you don't know it. SQLite has been trending among developers for its ability to host small data very quickly, safely, and contained in a single file. Go is one of the hottest languages in development right now, known for its simple structure and blazing performance. By the time you finish this tutorial, you can build CRUD (Create Read Update Delete) applications with Go easily. After your database is created and your first table is added, you can add some records.Today we're going to learn how to use SQLite with Go. If the tool categories are “hammer,” “spanner,” and “screwdriver,” you can’t add a record of type “chisel.”Ĭlick “OK” after you add the fields you want. For example, in a database of workshop tools, you might have a table of individual tools and another table of tool categories.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |