This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| //imports the package fmt | |
| import "fmt" | |
| //this is a Variadic function where it takes integers as params | |
| func sum(numbers ...int) int { | |
| total := 0 | |
| for result := range numbers { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| ) | |
| //This is how we declare a struct | |
| type UserDetail struct { | |
| firstName string | |
| lastName string |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| ) | |
| //This is how we declare a struct | |
| type UserDetail struct { | |
| firstName string | |
| lastName string |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| ) | |
| //Defined a struct with name and salaryPerMonth field | |
| type UserDetails struct { | |
| name string | |
| salaryPerMonth int |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| ) | |
| type UserDetail struct { | |
| name string | |
| age int | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| ) | |
| //This is how we declare the interface | |
| type operations interface { | |
| addition() float64 | |
| multiplication() float64 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| //the import packages | |
| import ( | |
| "fmt" | |
| "time" | |
| ) | |
| //a function which prints the string "s" for 5times | |
| func say(s string) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| //import packages | |
| import ( | |
| "fmt" | |
| ) | |
| func main() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import "fmt" | |
| func main() { | |
| //initialised the channel | |
| channelName := make(chan string, 2) | |
| //sends a string value to the channel | |
| channelName <- "Himanshu" | |
| //sends a second string value to the channel |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| ) | |
| //created a function with two paramenter with size and channel | |
| func fibonacci(n int, c chan int) { | |
| x, y := 1, 1 | |
| for i := 0; i < n; i++ { |