Skip to content

Instantly share code, notes, and snippets.

@Segmentational
Segmentational / public.goleaser.yaml
Created March 28, 2025 03:43
Public Go Releaser CLI
version: 2
project_name: example-cli
env_files:
github_token: ~/.config/goreleaser/github_token
before:
hooks:
- go vet
@Segmentational
Segmentational / K8s-Kustomization-Secrets-Documentation.md
Last active March 27, 2025 23:30
General GitOps Secrets Generator Documentation. Please note there are much better, more secure and scalable, setups for Kubernetes secrets.

Secrets

Secrets Generation

Various secrets need to be "hydrated" prior to running any kustomizations.

Specifically, each cluster will contain a secrets directory that contains a secretGenerator directive. Various files will need to be established under a nested .secrets directory.

@Segmentational
Segmentational / parallel-commands-executions.main.go
Last active March 6, 2025 03:24
Parallel Command Executions
package main
import (
"bufio"
"bytes"
"context"
_ "embed"
"encoding/json"
"errors"
"fmt"
@Segmentational
Segmentational / .gitlab-ci.yml
Last active January 25, 2025 02:22
Go, Cobra, CLI, Homebrew, Makefile, GitLab, Go-Releaser
stages:
- Testing
- Version
- Build
- Registry
Unit-Tests:
stage: Testing
image: golang:1.22-alpine
script:
@Segmentational
Segmentational / Makefile
Last active March 28, 2025 03:53
Go Makefiles for Homebrew taps and Other Applications
# Setting SHELL to bash allows bash commands to be executed by recipes.
# Options are set to exit when a recipe line exits non-zero or a piped command fails.
SHELL = /usr/bin/env bash -o pipefail
.SHELLFLAGS = -ec
# ====================================================================================
# Project Specific Globals
# ------------------------------------------------------------------------------------
#
@Segmentational
Segmentational / main.go
Created August 13, 2024 08:15
Go HTTP Proxy
package main
import (
"fmt"
"log"
"net/http"
"net/http/httputil"
"net/url"
"strings"
"time"
// Package namesgenerator generates random names.
//
// This package is officially "frozen" - no new additions will be accepted.
//
// For a long time, this package provided a lot of joy within the project, but
// at some point the conflicts of opinion became greater than the added joy.
//
// At some future time, this may be replaced with something that sparks less
// controversy, but for now it will remain as-is.
//
@Segmentational
Segmentational / Deployment.yaml
Created February 25, 2024 01:50
Kubernetes Deployment Downward API Environment Variables
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: api-deployment
labels:
name: api-deployment
spec:
replicas: 2
selector:
@Segmentational
Segmentational / Dockerfile
Last active February 18, 2024 23:29
Optimized GO HTTP Server Dockerfile - Kubernetes, Private VCS Compatible
# syntax = docker/dockerfile:1.0-experimental
FROM golang:1.22-alpine as BUILD
# ARG NETRCPASSWORD
# ENV NETRCPASSWORD "${NETRCPASSWORD}"
# ENV GOPRIVATE "github.com/example/*"
ENV GOOS "linux"
ENV GOVCS "*:all"
@Segmentational
Segmentational / main.go
Created December 18, 2023 08:59 — forked from creack/main.go
A simple golang web server with basic logging, tracing, health check, graceful shutdown and zero dependencies
package main
import (
"context"
"fmt"
"log"
"net/http"
"os"
"os/signal"
"strconv"