Skip to content

Instantly share code, notes, and snippets.

@victorsteven
Created June 24, 2019 09:19
Show Gist options
  • Select an option

  • Save victorsteven/da05999cd899de6ba120a04fff6fa45e to your computer and use it in GitHub Desktop.

Select an option

Save victorsteven/da05999cd899de6ba120a04fff6fa45e to your computer and use it in GitHub Desktop.
package main
import "fmt"
//Package scope array definition
var integerSlice []int
var stringSlice []string
func main() {
integerSlice = []int{10, 20, 30, 40}
fmt.Println("This is the integer Slice: ", integerSlice)
stringSlice = []string{"first", "second", "third"}
fmt.Println("This is the string slice: ", stringSlice)
printInteger()
}
//This function can access the integerSlice because integerSlice is package scoped
func printInteger() {
fmt.Println("Print the integers: ", integerSlice)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment