1. package main
    2. import (
    3. "fmt"
    4. )
    5. func change(s ...string) {
    6. fmt.Printf("#1 address of s[0] is %p and it's content is %s and it's len is %d \n", &s[0], s, len(s))
    7. s[0] = "Go"
    8. s = append(s, "playground")
    9. fmt.Printf("#2 address of s[0] is %p and it's content is %s and it's len is %d \n", &s[0], s, len(s))
    10. }
    11. func main() {
    12. enough := make([]string, 10, 10)
    13. enough[0] = "The"
    14. enough[1] = "First"
    15. change(enough[0:2]...)
    16. fmt.Printf("111111address of enough[0] id %p and it's content is %s and it's len is %d \n", &enough[0],
    17. enough, len(enough))
    18. notEnough := make([]string, 2, 2)
    19. notEnough[0] = "The"
    20. notEnough[1] = "Second"
    21. change(notEnough[0:2]...)
    22. fmt.Printf("2222222address of notEnough[0] id %p and it's content is %s and it's len is %d \n", &notEnough[0],
    23. notEnough, len(notEnough))
    24. /*
    25. In the second case, the "append" function of change() creates a new array of double size and returns
    26. the pointer to it. s now points to this new array. But in the main function nowEnough still points to the
    27. old array of size 2.
    28. */
    29. }