Stackgo
A slice-based implementation of a stack. In Go!
Install / Use
/learn @alediaferia/StackgoREADME
Stackgo

Stackgo is a slice-based implementation of a simple stack in Go. It uses a pre-alloc pagination strategy which adds little memory overhead to the stack allocation but makes push operations faster than with a classic Stack implementation.
Please NOTE that the current implementation is NOT thread-safe.
Getting started
Import
You can either import this package directly:
import "github.com/alediaferia/stackgo"
or through gopkg.in
import "gopkg.in/alediaferia/stackgo.v1"
Currently only version 1 has been released.
Usage
Using it is pretty straightforward
package main
import (
"github.com/alediaferia/stackgo"
"fmt"
)
func main() {
stack := stackgo.NewStack()
// Stack supports any type
// so we just push whatever
// we want here
stack.Push(75)
stack.Push(124)
stack.Push("Hello World!")
for stack.Size() > 0 {
fmt.Printf("Just popped %v\n", stack.Pop())
}
}
Performance
Check the implementation details here.
Contribute
I'd really appreciate contributions, otherwise I wouldn't have made this open :smiley:. Also, if you have suggestions on how to make this perform even faster I'd be really happy to hear about them.
License
This code is released under the MIT License term, included in this project tree. Copyright © 2015, Alessandro Diaferia alediaferia@gmail.com
Related Skills
node-connect
351.8kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
110.9kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
351.8kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
351.8kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
