Resources
Answers
Examples
Sign in
Get Started
What do you want to save?
Add Code snippet
New code examples
Go
2022-02-14 01:40:12
golang return function
// Function with int as return type func add(x int, y int) int { total := 0 total = x + y return total } func main() { // Accepting return value in varaible sum := add(20, 30) fmt.Println(sum) }
Add solution
Go
2022-02-11 09:40:06
while in golang
package main import "fmt" func main() { sum := 1 for sum < 10 { fmt.Println(sum) sum++ } }
Add solution
Go
2022-02-02 22:00:37
bubble sort in golang
package main import ( "fmt" "os" "strconv" ) func bubblesort() { unsorted := os.Args[1:] var data [5]int for i, n := range unsorted { value, err := strconv.Atoi(n) data[i] = value if err != nil { data[i] = 0...
Add solution
Go
2022-02-01 07:05:56
golang size of slice
// Create an exmaple array array := []int{1, 2, 3, 4, 5} // Print number of items fmt.Println("First Length:", len(array))
Add solution
Go
2022-02-01 02:36:41
go switch case
switch time { case "morning": fmt.Println("Time to wake up!") case "night": fmt.Println("Time to go to bed.") default: fmt.Println("Enjoy life") }
Add solution
Go
2022-01-31 22:25:20
slice in golang
// Use of golang slice func main() { // initialise the slice with 10 zero ints slice := make([]int, 10) // fillup with random ints fillSliceWithRand(slice) // prints the slice print(slice) // passes the slice by reference and reverse th...
Add solution
Go
2022-01-31 09:17:27
golang read file line by line
package main import ( "bufio" "bytes" "fmt" "io" "os" ) func readFileWithReadString(fn string) (err error) { fmt.Println("readFileWithReadString") file, err := os.O...
Add solution
Go
2022-01-31 08:05:01
type switch golang
var value interface{} = "Hello Grepper" switch vale.(type){ case string: fmt.Println("It is a string") case int: fmt.Println("It is a int") default: fmt.Println("Not sure") }
Add solution
Go
2022-01-29 03:06:28
select channel golang
package main import ( "fmt" ) func main() { c := make(chan int) go sender(c) receiver(c) } func sender(c chan<- int) { defer close(c) for i := 0; i < 10; i++ { c <- i } } func receiver(c <-chan int) { for { select {...
Add solution
Other
2022-01-23 05:30:40
go hello world
// First Go program package main import "fmt" // Main function func main() { fmt.Println("!... Hello World ...!") }
Add solution
‹
1
2
3
4
5
6
7
8
9
10
11
12
›
Best helpers
daily
weekly
monthly
for 3 months
John Gotti
+5
Rookie
+5
Jagoda Tajchert
+5
Jeffrywith1e
+5
show more
This website uses cookies to make IQCode work for you. By using this site, you agree to our
cookie policy
Welcome Back!
Sign up to unlock all of IQCode features:
Test your skills and track progress
Engage in comprehensive interactive courses
Commit to daily skill-enhancing challenges
Solve practical, real-world issues
Share your insights and learnings
Sign in
E-mail
Password
Recover lost password
Log in
Or log in with
Not registered?
Sign up takes less than a minute
Create a Free Account
Sign up to unlock all of IQCode features:
Test your skills and track progress
Engage in comprehensive interactive courses
Commit to daily skill-enhancing challenges
Solve practical, real-world issues
Share your insights and learnings
Sign up
Email
Password
Sign up for free
Or sign up with
By signing up, you agree to the
Terms and Conditions
and
Privacy Policy
. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.