package main

import "fmt"

// section: types
type UserID int
type ProductID int

// section: types

// section: funcs
func GetUser(id UserID) {
	fmt.Printf("Getting user with ID: %d\n", id)
}

func GetProduct(id ProductID) {
	fmt.Printf("Getting product with ID: %d\n", id)
}

// section: funcs

func main() {
	// section: main
	var uid UserID = 1
	var pid ProductID = 1

	GetUser(uid)    // Works
	GetProduct(pid) // Works

	// GetUser(pid) // Compiler error: cannot use pid (type ProductID) as type UserID
	// GetProduct(uid) // Compiler error: cannot use uid (type UserID) as type ProductID

	// Even though both are "1", they are different types!
	// This prevents accidentally mixing user IDs with product IDs
	// section: main
}

/*
// section: output
$ go run main.go
Getting user with ID: 1
Getting product with ID: 1
// section: output
*/
