Skip to content

Instantly share code, notes, and snippets.

View hi-manshu's full-sized avatar

Himanshu Singh hi-manshu

View GitHub Profile
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 {
package main
import (
"fmt"
)
//This is how we declare a struct
type UserDetail struct {
firstName string
lastName string
package main
import (
"fmt"
)
//This is how we declare a struct
type UserDetail struct {
firstName string
lastName string
package main
import (
"fmt"
)
//Defined a struct with name and salaryPerMonth field
type UserDetails struct {
name string
salaryPerMonth int
package main
import (
"fmt"
)
type UserDetail struct {
name string
age int
}
package main
import (
"fmt"
)
//This is how we declare the interface
type operations interface {
addition() float64
multiplication() float64
package main
//the import packages
import (
"fmt"
"time"
)
//a function which prints the string "s" for 5times
func say(s string) {
package main
//import packages
import (
"fmt"
)
func main() {
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
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++ {