When an identifier starts with a lowercase letter, the identifier is unexported or unknown to code outside the package.
    When an identifier starts with an uppercase letter, it’s exported or known to code outside the package.

    The Newfunction is returning a value of the unexported type alertCounter, and main is able to accept that value and
    create a variable of the unexported type.

    1. //counters/counters.go
    2. //-----------------------------------------------------------------------
    3. package counters
    4. type alertCounter int
    5. func New(value int) alertCounter {
    6. return alertCounter(value)
    7. }
    8. //listing68.go
    9. //-----------------------------------------------------------------------
    10. package main
    11. import (
    12. "fmt"
    13. "counters"
    14. )
    15. func main() {
    16. counter := counters.New(10)
    17. fmt.Printf("Counter: %d\n", counter)
    18. }

    This is possible for two reasons:

    1. identifiers are exported or unexported, not values.
    2. the short variable declaration operator is capable of inferring the type and creating a variable of the unexported type.

      You can never explicitly create a variable of an unexported type, but the short variable declaration operator can.