Coding Interview Questions
Comprehensive coding interview questions covering algorithms, data structures, and problem-solving techniques with Go implementations. Data Structures Detailed explanations and implementations of core data structures: Binary trees and BSTs Heaps and priority queues Tries and advanced trees Linked lists and arrays Hash โฆ
Read MoreHomomorphic encryption allows computation on encrypted data without decryption, enabling privacy-preserving computations. Core Idea Homomorphic Encryption (HE) enables operations on ciphertexts that correspond to operations on plaintexts: $$\text{Decrypt}(E(m_1) \odot E(m_2)) = m_1 \circ m_2$$ where: $E(m)$ is the โฆ
Read MoreCobra is a powerful library for creating modern CLI applications in Go. Used by kubectl, Hugo, GitHub CLI, and many other popular tools. Provides commands, subcommands, flags, and automatic help generation. Use Case Use Cobra when you need to: Build complex CLI tools with subcommands Provide consistent flag handling โฆ
Read MoreStandard Go project layout following community conventions. Organize your Go projects for maintainability, testability, and clarity. Use Case Use this structure when you need to: Start a new Go project Organize a growing codebase Follow Go community standards Prepare for open source release Standard Layout 1myproject/ โฆ
Read MoreTechniques for building small, efficient Docker images with focus on Alpine, scratch, and Go binaries. Multi-Stage Builds Basic Multi-Stage Build 1# Build stage 2FROM golang:1.21-alpine AS builder 3WORKDIR /app 4COPY go.mod go.sum ./ 5RUN go mod download 6COPY . . 7RUN go build -o myapp 8 9# Final stage 10FROM โฆ
Read MoreAuthentication and authorization middleware patterns for Go web applications. Includes JWT, OAuth2, Auth0, and CORS implementations. Use Case Protect API endpoints with authentication Implement role-based access control Integrate with OAuth providers (Auth0, Google, GitHub) Handle CORS for frontend applications JWT โฆ
Read MoreCommon code smells in Go and how to fix them. Ignoring Errors 1// โ Bad 2result, _ := doSomething() 3 4// โ Good 5result, err := doSomething() 6if err != nil { 7 return fmt.Errorf("failed: %w", err) 8} Not Using defer 1// โ Bad 2file, err := os.Open("file.txt") 3if err != nil { 4 return err 5} 6data, โฆ
Read MoreGo modules and workspaces for dependency management. Essential commands for Go project management. Initialization 1# Initialize new module 2go mod init example.com/myproject 3go mod init github.com/username/repo 4 5# Initialize in existing directory 6cd myproject 7go mod init example.com/myproject go.mod file: 1module โฆ
Read MoreSecure coding practices for Go applications. SQL Injection Prevention 1// โ Vulnerable 2username := r.FormValue("username") 3query := fmt.Sprintf("SELECT * FROM users WHERE username = '%s'", username) 4db.Query(query) 5 6// โ Secure 7username := r.FormValue("username") 8query := โฆ
Read MoreTools for checking vulnerabilities in Go code. Govulncheck 1# Install 2go install golang.org/x/vuln/cmd/govulncheck@latest 3 4# Check current module 5govulncheck ./... 6 7# JSON output 8govulncheck -json ./... Gosec 1# Install 2go install github.com/securego/gosec/v2/cmd/gosec@latest 3 4# Scan project 5gosec ./... 6 7# โฆ
Read MoreGo examples for accessing Raspberry Pi GPIO, I2C, SPI, and PWM using periph.io. Installation 1# Install Go (if not already installed) 2wget https://go.dev/dl/go1.21.5.linux-arm64.tar.gz 3sudo tar -C /usr/local -xzf go1.21.5.linux-arm64.tar.gz 4 5# Add to PATH 6echo 'export PATH=$PATH:/usr/local/bin/go/bin' โฆ
Read More
I've been involved in Full Stack for a while now in one form or another(either maintaining, designing or working on Full Stack projects). Even during school time, I was building websites for myself and my friends. I've built sites commercially even. Although I've been using either pure HTML+JS or even PHP/Perl at some โฆ
Read More