Premium Tutorials • Books • Articles • Modern Programming Paths Go Programming Book · Author Bookstore
Lesson 15 of 15

Final Mini Project: Student Records App

Create a small student records app using structs, slices, functions, and loops.

Beginner Friendly Runnable Example Go Programming
Learning objective: Build a mini project that combines multiple Go fundamentals.

Project Goal

The final mini project combines several beginner Go concepts into one simple application.

Data Model

Use a Student struct to store each student's name and score.

Displaying Records

Use a function to loop through all students and display their details.

Example Code

Create or update your Go file, then run the program using go run main.go.

package main

import "fmt"

type Student struct {
    Name  string
    Score int
}

func displayStudents(students []Student) {
    fmt.Println("Student Records")
    fmt.Println("---------------")

    for _, student := range students {
        fmt.Println(student.Name, "-", student.Score)
    }
}

func averageScore(students []Student) float64 {
    total := 0

    for _, student := range students {
        total += student.Score
    }

    return float64(total) / float64(len(students))
}

func main() {
    students := []Student{
        {Name: "Ali", Score: 88},
        {Name: "Mei", Score: 95},
        {Name: "John", Score: 76},
    }

    displayStudents(students)
    fmt.Println("Average score:", averageScore(students))
}
Key points to remember
  • This project uses structs, slices, functions, loops, and calculations.
  • You can extend it by adding user input.
  • You can later save student records into a file.

Practice Exercises

  1. Add more students to the slice.
  2. Display only students who score above 80.
  3. Add a function to find the highest score.

Continue Learning

After this lesson, continue to the next lesson or explore related tutorials on VisualStudioTutor.com.