go create list length

package main

import "fmt"

type Node struct {
    data int
    next *Node
}

type LinkedList struct {
    head *Node
}

func (ll *LinkedList) addNode(data int) {
    newNode := &Node{data: data, next: ll.head}
    ll.head = newNode
}

func (ll *LinkedList) getListLength() int {
    current := ll.head
    length := 0

    for current != nil {
        length++
        current = current.next
    }

    return length
}

func main() {
    list := LinkedList{}

    // Adding nodes to the linked list
    list.addNode(3)
    list.addNode(7)
    list.addNode(11)

    // Getting the length of the linked list
    length := list.getListLength()

    // Printing the length
    fmt.Printf("Length of the linked list: %d\n", length)
}