Last active
July 18, 2020 21:54
-
-
Save 178inaba/b6fa5c6d8daf9732669591f12fe0c653 to your computer and use it in GitHub Desktop.
Pop multiple slice. https://play.golang.org/p/RPwjo1HG_dI
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() { | |
a := make([]int, 5001) | |
for i := 0; i < 5001; i++ { | |
a[i] = i | |
} | |
//fmt.Println(a[50000:]) | |
for { | |
var x []int | |
if len(a) == 0 { | |
break | |
} else if len(a) < 500 { | |
x, a = a[:len(a)], a[len(a):] | |
} else { | |
x, a = a[:500], a[500:] | |
} | |
test(x) | |
} | |
fmt.Println("for end") | |
fmt.Println(a) | |
fmt.Println(len(a)) | |
} | |
func test(x []int) { | |
fmt.Println(x) | |
fmt.Println(len(x)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment