Skip to main content

All Questions

Tagged with
1 vote
1 answer
63 views

How do you flatten a slice of arrays without extra allocation?

In Go, if I have a slice of arrays of a given type, how can I convert that to just a slice of that same type? Specifically, is it possible to do this without allocating memory for a new backing array? ...
Venning's user avatar
  • 852
-1 votes
1 answer
64 views

How can I increase the stack size limit in a Go program?

I'm running a recursive implementation of the Quick Sort algorithm for my Algorithms Design class. My project requires me to run the algorithm with arrays from size 100 to size 10^8. The algorithm can ...
Luis Sanchez's user avatar
-4 votes
1 answer
57 views

Problem with recursive function that sums all numbers in array in Go

I want to sum all the numbers in array using recursive function import ( "fmt" ) func RemoveIndex(s []int, index int) []int { return append(s[:index], s[index+1:]...) } func ...
Tarik's user avatar
  • 1
2 votes
2 answers
67 views

go lang: view []uint32 array as []uint8

what is the most efficient way in Go to view uint32 array as uint8 array? for now my solution in go is quite clumsy and involves a lot of unnecessary binary arithmetic: import "fmt" func ...
Daniil Zuev's user avatar
1 vote
1 answer
119 views

multidimensional slice access performance in golang

I am working on a little and simple game-of-life in Golang and stumbled on a performance problem during slice access. This is the primary data structure for the game: type Neighbor struct { X, Y ...
Tom's user avatar
  • 119
0 votes
1 answer
102 views

GoLang - looping through array of structs - can I map?

I'm new to GoLang, coming from Node. A little late to the (definitely not functional) game and need some help understanding approaches, and perhaps just understanding... I want to omit an item from a ...
Harry Lincoln's user avatar
0 votes
1 answer
71 views

How to create a generic array in GO?

I have a function that needs to receive a GORM model as a parameter, and depending on the model I receive as a parameter, I need to create an Array(Slice) based on the type of the struct(gorm model) I ...
Gustavo Piucco's user avatar
-1 votes
1 answer
58 views

Go, 2-dimensional array (or slice) of struct [duplicate]

The following go-code works fine: package main import ( "fmt" ) type Node struct { north int east int south int west int } func main() { roomsX := 5 roomsY := 5 ...
Swiftiti's user avatar
0 votes
2 answers
1k views

What's the fastest way to check if a list contains an item in Go?

I have a project where performance is very important. The function I have to check if a list contains an item is being called hundreds of thousand to millions of times per second, and is costing me a ...
Flummox's user avatar
  • 83
1 vote
1 answer
50 views

Scan-read trouble when a big number appears Golang

Trying to solve https://codeforces.com/problemset/problem/803/B My code works fine for smaller inputs, but it keeps getting runtime-error when tests with big numbers appear(9-digit numbers). it throws ...
aTired1's user avatar
  • 11
0 votes
0 answers
59 views

How to handle large amount of data from array of pointer struct faster in Golang?

I want to create a CSV file from []*dto.Customer. Getting all values and convert each struct values into a single string & then push into an array. Finally write into string builder then convert ...
Hariharan Panneerselvam's user avatar
0 votes
0 answers
54 views

Quadtree of 2D array

so we have this project where we have to build a quadtree from a 2D array in parameters, the thing is my inital code doesn't manage well rectangle arrays when i want to expand the length of the width ...
Dannette15's user avatar
1 vote
0 answers
62 views

Printing cosmetic extras when turning a 3D rubix cube array into ASCII art

I have a 4D array that I'm using to create a rubix cube, the dimensions are depth, height, width, and face, each given a letter to determine what color that face should be. Here is an image for ...
Corndog333's user avatar
-1 votes
1 answer
85 views

Go: appending the second item changes the first item [closed]

Don't know what to say, just look at the code and at the output. Code: package main import ( "encoding/json" "fmt" ) type Human struct { N string `json:"n"` ...
max's user avatar
  • 11
0 votes
0 answers
93 views

Slicing a two dimensional array

I'm trying to learn to take advantage of all the benefits that slices offer. The challenge task I created for myself was to create a slice for two dimensional array (even dimension) so that the lower ...
elklepo's user avatar
  • 517

15 30 50 per page
1
2 3 4 5
72