#how to add strings to a string

16 messages · Page 1 of 1 (latest)

tranquil obsidian
#

I have this line of code
grids := make([]*gim.Grid, len(images))
That adds images from a set of variables. But to make it work the way i need to I can't have the entire images path in images which would normally be images/01.png, images/01.png, images/01.png but I need to have an easier input for users so I have had to change images to 01 01 01

For this to work I need to change the grids bit into
grids := make([]*gim.Grid, "images/" + len(images) + ".png") but I get this error when trying so.

Any help in how to correctly add "images/" and ".png" would help a lot 🙂

#

Full code if needed

drifting plaza
#

"images/1.png" is not exactly a length

#

You perhaps trying to do make([]*gim.Grid, len(images))?

tranquil obsidian
#

ohh I see that makes more sense sorry, I had someone else help work on that bit and they fell asleep before I could ask them to explain what it all means

#

I'll work through the code more and find where I'm meant to do what I'm trying to do aha

#

With strings.Split(s, " ") how could I also add text to the start and end of each split

drifting plaza
#

It is unclear what you are asking

tranquil obsidian
#

I'm trying to split "I1 I1 I1" into "images/I1.png", "images/I1.png", "images/I1.png"

tranquil obsidian
#

Solved

sudden edge
tranquil obsidian
#

I'll keep this in mind for the future but was able to do it with just {imageFilePath: "images/" + path + ".png"}

sudden edge
#

the point of filepath.Join is that it join correctly based on the OS

#

where windows uses \