Go Slices Are Values

Go Slices Are Values

But what does that really look like behind the scenes?

But what does that really look like behind the scenes?

Since my last post, I realized that slices in Go actually deserve a little more discussion. For example, the two following code snippets are actually quite different.

Go code which creates a slice and calls a function that appends to the slice and then mutates the slice.

Go code that creates a slice, then calls a function which mutates that slice and then appends to it.

The first prints a friendly “[got] [hi]” where the second prints a very meta “[got] [go]”! What’s up with this? Well, to start, we have to understand how slices work a little better. And what better place to start than the Go runtime itself.

type slice struct {
    array unsafe.Pointer
    len int
    cap int
}

golang programming

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Golang Web Development:Th Best Programming Language in 2020

Golang Web Development is the new trend globally. Get all the details about the Golang development here. Hire Golang Developers.

Programming In Acceleration: Levelling Up Programming Skills

Some require and some are not. But acceleration programs might require you to build one. I’ll tell you how I made a computer program for the competition.

Golang Tutorial #1 - An Introduction to Go Programming

An introduction to the go programming language for beginners. In this golang tutorial you will learn the basics of go, setup a go lang coding environment and...

Golang Array Example | Arrays in Go Tutorial Explained

Golang array is a fixed-size collection of items of the same type. The items of an array are stored sequentially and can be accessed using their index.

"Interview Prep - Golang" Course Released

We just launched Interview Prep - Golang, a quick course for those looking to brush up on some Go quirks before walking into an interview. The course is a