Project Setup
Part of the Logic & Flow section of Coddy's GO journey — lesson 20 of 68.
Challenge
EasyOver the next few lessons, you'll build a simple command-line task list application that lets users add, view, complete, and remove tasks.
In this challenge, you'll create the foundation for a task management system by setting up the basic data structure and user interface. This is the first step in building a complete task list application that will grow throughout the project.
You will receive two inputs:
- A string representing the application name (e.g.,
"MyTasks") - A string representing the user's name (e.g.,
"Alice")
Your task is to:
- Define a
Taskstruct with two fields:Name(string) - the task descriptionCompleted(bool) - whether the task is finished
- Create a slice of
Taskstructs to hold your task list (initially empty) - Display a welcome message in the format:
"Welcome to [app_name], [user_name]!" - Display a menu with the following options, each on a separate line:
"1. Add Task""2. View Tasks""3. Complete Task""4. Remove Task""5. Exit"
- Print the current number of tasks in the format:
"Current tasks: [count]"
This challenge establishes the core structure that will support all future functionality in your task management system. The Task struct will be the building block for storing individual tasks, while the slice will manage your collection of tasks. The menu provides a clear interface for users to understand what actions they can perform.
Try it yourself
package main
import "fmt"
func main() {
// Read input
var appName string
var userName string
fmt.Scanln(&appName)
fmt.Scanln(&userName)
// TODO: Write your code below
// Define the Task struct
// Create a slice of Task structs
// Display welcome message and menu
// Print current tasks count
}All lessons in Logic & Flow
1Advanced Control Flow
Switch with `fallthrough`Breaking from Nested LoopsContinuing a Specific LoopThe `goto` StatementRecap - Advanced Loop Control4Project: Simple Task List
Project SetupAdding a Task2Structs and Methods
Defining Methods on StructsValue ReceiversPointer ReceiversChoosing ReceiversMethods vs FunctionsRecap - Struct Behavior5Maps In-Depth
Maps of StructsPointers as Map ValuesTesting for Nil MapsComparing MapsRecap - Word Frequency Counter3Interfaces (The Basics)
What is an Interface?Defining an InterfaceImplementing an InterfaceUsing Interface TypesEmpty InterfaceType AssertionsType SwitchRecap - Shapes and Behaviors