FlareStart
HomeNewsHow ToSources
FlareStart

Where developers start their day. All the tech news & tutorials that matter, in one place.

Quick Links

  • Home
  • News
  • Tutorials
  • Sources
  • Privacy Policy

Connect

© 2026 FlareStart. All rights reserved.

Back to articles
Go Slices: Loop over append function
How-ToTools

Go Slices: Loop over append function

via Dev.to TutorialGanesh Kumar1mo ago

Hello, I'm Ganesh Kumar. I'm working on git-lrc : a Git hook for Checking AI generated code.AI agents write code fast. They also silently remove logic, change behavior, and introduce bugs -- without telling you. You often find out in production.git-lrc fixes this. It hooks into git commit and reviews every diff before it lands. 60-second setup. Completely free. In my previous post, I explained about append function algorithm Now let's see how loop works with append function Loop over append function Let's assign the power of 2 to a slice and print it. With normal loop we can print the slice. We basicaly loop over the length of the slice using the index. package main import "fmt" var power = [] int { 1 , 2 , 4 , 8 , 16 , 32 } func main () { for i := 0 ; i < len ( power ); i ++ { fmt . Printf ( "2^%d = %d \n " , i , power [ i ]) } } This will output: 2^0 = 1 2^1 = 2 2^2 = 4 2^3 = 8 2^4 = 16 2^5 = 32 Go inbuilt range function Go provides a very simple way to loop over a slice. package mai

Continue reading on Dev.to Tutorial

Opens in a new tab

Read Full Article
19 views

Related Articles

150 million users later, Roblox competitor Rec Room is shutting down
How-To

150 million users later, Roblox competitor Rec Room is shutting down

The Verge • 1d ago

Here are our favorite spring cleaning deals from Amazon’s Big Spring Sale
How-To

Here are our favorite spring cleaning deals from Amazon’s Big Spring Sale

The Verge • 1d ago

What we’re looking for in Startup Battlefield 2026 and how to put your best application forward
How-To

What we’re looking for in Startup Battlefield 2026 and how to put your best application forward

TechCrunch • 1d ago

Build Days That Actually Mean Something
How-To

Build Days That Actually Mean Something

Medium Programming • 1d ago

I have blogged about the difference between code coverage and test coverage and why it matters to distinguish between these 2.
How-To

I have blogged about the difference between code coverage and test coverage and why it matters to distinguish between these 2.

Dev.to Beginners • 2d ago

Discover More Articles