Skip to content

Instantly share code, notes, and snippets.

View ObsidianCat's full-sized avatar

Lula Leus ObsidianCat

View GitHub Profile
@ObsidianCat
ObsidianCat / go-slices-as-param.go
Created June 28, 2023 15:38
Unexpected behaviour of slices, when passed as argument in a function and mutated
package main
import (
"fmt"
)
func sliceExtender(sl []int) {
sl = append(sl, 33)
sl[0] = 5
fmt.Printf("len %d, cap %d, sliceOne[0]=%d, added last elemnt =%d \n", len(sl), cap(sl), sl[0], sl[len(sl)-1])
package main
import (
"fmt"
)
type steps struct {
dayOfTheWeek string
greeting string
tasks []string
function buildItenary(options, startCity) {
const citiesMap = new Map()
options.forEach(([origin, dest]) => {
if (citiesMap.has(origin)) {
const stored = citiesMap.get(origin)
stored.push(dest)
citiesMap.set(origin, stored)
} else {
citiesMap.set(origin, [dest])
}
package main
import (
"errors"
"fmt"
customError "github.com/pkg/errors"
)
type stackTracer interface {