Skip to content

Instantly share code, notes, and snippets.

@ridhoperdana
Created December 30, 2020 05:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ridhoperdana/178e3c547924e09852e319ed0399e150 to your computer and use it in GitHub Desktop.
Save ridhoperdana/178e3c547924e09852e319ed0399e150 to your computer and use it in GitHub Desktop.
example of multiple task inside 1 function
package main
import (
"fmt"
)
func addEngineerAndPrintNames(currentEngineer []string, newEngineer string) (updatedEngineers []string) {
updatedEngineers = append(currentEngineer, newEngineer)
for index, engineer := range updatedEngineers {
fmt.Printf("Some string at index %v with value %v", index, engineer)
}
return updatedEngineers
}
func main() {
engineers := []string{"John", "Doe", "Budi"}
engineers = addEngineerAndPrintNames(engineers, "Agus")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment