How to do it in range in go lang

Dear Expert,

I would like to ask some help from you about go lang programming. I’m beginner in go programming, i don’t know to come-up with a solution for my problem. I don’t know if the problem is the array, slice, range or what but my issue I want it the same on the output bellow.

The array goes here is like this.

 	Company=:[{1 Toyota} {2 Izuzu} {3 Ford}]
    Cars: [{A Hilux} {B Hi-Ace}][{A DMAX} {B Bus}][{A Ranger}{B Focus}]
    Color:[{White Red}][{Black Red}][{Blue Red}][{Blue Red}][{Blue Red}][{Blue Red}]

I want the output will be like this.

1 Toyota
   A Hilux
	  White
	  Red
   B Hi-Ace
	  White
	  Red
2 Izuzu
   A DMAX
	  White
	  Red
   B Bus
	  White
	  Red
3 Ford
   A Ranger
	  White
	  Red
   B Focus
	  White
	  Red

Please help.

Thank you in advance

This Document Will Help You Solve Your Problem.
https://gobyexample.com/range

I don’t know what you are trying to accomplish, if you are just trying to practice with slices and range or what. You have inspired me to write a little example of how you could get your output using structs and range: https://play.golang.org/p/yUUdnqGNO-0

2 Likes

@CurtGreen can i say bad word? ■■■■ you nailed it man… thanks alot…how to give you more credit on this forum?

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.