Skip to content

Instantly share code, notes, and snippets.

View Goodnessuc's full-sized avatar
🎯
Focusing

Ukeje Chukwuemeriwo Goodness Goodnessuc

🎯
Focusing
View GitHub Profile
@Goodnessuc
Goodnessuc / jwt.go
Created July 24, 2022 15:33
JWT tutorial in Go using the golang-jwt package
package main
import (
"encoding/json"
"fmt"
"github.com/golang-jwt/jwt"
"log"
"net/http"
"time"
)
@Goodnessuc
Goodnessuc / gith.go
Created December 30, 2023 08:42
GitHub OAuth Golang
package main
import (
"context"
"encoding/json"
"fmt"
"golang.org/x/oauth2"
"golang.org/x/oauth2/github"
"io"
"net/http"
@Goodnessuc
Goodnessuc / controller.go
Created November 8, 2022 11:46
Updates to LogRocket's Gin Gonic tutorial article
package controllers
import (
"Go-Tutorials/models"
"github.com/gin-gonic/gin"
"net/http"
)
type CreateBookInput struct {
Title string `json:"title" binding:"required"`
@Goodnessuc
Goodnessuc / gin.go
Last active January 18, 2024 09:24
CRUD API in Go using the Gin FrameWork - Article for Earthly Technologies
package main
import (
"github.com/gin-gonic/gin"
"gorm.io/driver/sqlite"
"gorm.io/gorm"
"log"
"net/http"
)
@Goodnessuc
Goodnessuc / gitlab.go
Created December 30, 2023 09:33
GitLab Oauth Example
package main
import (
"context"
"encoding/json"
"fmt"
"golang.org/x/oauth2"
"io"
"net/http"
)
@Goodnessuc
Goodnessuc / randomgenerator.go
Last active November 10, 2023 13:02
Generate Cryptographically secure random values of any type in Go
// In this script, we'll create a function to generate secure random strings.
// First, define the function that generates the random string.
func generateRandomString(chars string, length int) string {
// Create an array of bytes with the specified length.
bytes := make([]byte, length)
// Use crypto/rand to fill the byte array with secure random bytes.
_, err := rand.Read(bytes)
if err != nil {
@Goodnessuc
Goodnessuc / Dockerfile
Created September 22, 2023 02:47
My Typical Dockerfile
# Build stage
FROM golang:1.20-alpine AS build
# Set the working directory inside the container
WORKDIR /app
# Copy the Go application source code into the container
COPY . .
# Build the Go application
@Goodnessuc
Goodnessuc / optimize.go
Last active September 3, 2023 15:50
Full code for the Earthly Technologies Article on Optimizing SQL Queries
package main
import (
"fmt"
"gorm.io/driver/postgres"
"gorm.io/gorm"
"gorm.io/gorm/schema"
"log"
"time"
)
@Goodnessuc
Goodnessuc / fake_database.go
Last active September 3, 2023 14:26
A program that generates X no of rows of fake data for database insertion/operation (just modify the struct)
package main
import (
"github.com/brianvoe/gofakeit/v6"
"gorm.io/driver/postgres"
"gorm.io/gorm"
"log"
"time"
)
@Goodnessuc
Goodnessuc / PushaG.sh
Last active June 8, 2023 13:39
Helper file for pushing code to github with a commit message input
git add .
echo -n "🔊 What's the commit message 👉 "
read response
git commit -m "$response"
git push origin main