golang传参的问题

package main

import (
    "bufio"
    "fmt"
    "os"
)

func main() {
    counts := make(map[string]int)
    files := os.Args[1:]
    if len(files) == 0 {
        countLines(os.Stdin, counts)
    } else {
        for _, arg := range files {
            f, err := os.Open(arg)
            if err != nil {
                fmt.Fprintf(os.Stderr, "dup2:%v\n", err)
                continue
            }
            countLines(f, counts)
            f.Close()
        }
    }
    for line, n := range counts {
        if n > 1 {
            fmt.Printf("%d\t%s\t%s\n", n, line)
        }
    }
}

func countLines(f *os.File, counts map[string]int) {//问题在这里的counts
    input := bufio.NewScanner(f)
    for input.Scan() {
        out := input.Text()
        counts[out]++
    }
}

请问:程序能正常运行,我有个疑问:这个函数传入的counts,不是复制么,为什么能改变外部的counts,我记得好像要用引用(*counts)才能改变外部的counts?

查看回复