Skip to content

Instantly share code, notes, and snippets.

@IamNator
IamNator / main.go
Created June 14, 2024 06:42
Clean Database Transactions in Go with GORM
package main
import (
"context"
"fmt"
"gorm.io/driver/sqlite"
"gorm.io/gorm"
)
// Entity represents a database entity
package common
import (
"bytes"
"encoding/json"
"encoding/xml"
"io"
"net/http"
gourl "net/url"
"strings"
@ScMofeoluwa
ScMofeoluwa / env2json.go
Last active April 13, 2023 10:31
.env configs to json
package main
import (
"bufio"
"encoding/json"
"fmt"
"os"
"strings"
)
package oauth2
import (
"context"
"encoding/json"
"errors"
"fmt"
"inawo-services-api/pkg/env"
"os"
"time"

A simple Docker and Docker Compose install script for Ubuntu

Usage

  1. sh install-docker.sh
  2. log out
  3. log back in

Links

@joeke80215
joeke80215 / test_http.go
Created November 11, 2019 08:13
golang gin httptest example
package service
import (
"fmt"
"log"
"net/http"
"net/http/httptest"
"strings"
"testing"
@byyam
byyam / gin-json-schema.go
Last active September 6, 2021 11:28
gin json schema
package main
import (
"fmt"
"bytes"
"strings"
"io/ioutil"
"net/http"
"github.com/gin-gonic/gin"
"github.com/xeipuuv/gojsonschema"
)
@miguelmota
miguelmota / example.proto
Last active January 3, 2025 00:11
Golang protobuf marshal and unmarshal example
syntax = "proto3";
message Message {
bytes text = 1;
}
// HTTPError implements ClientError interface.
type HTTPError struct {
Cause error `json:"-"`
Detail string `json:"detail"`
Status int `json:"-"`
}
func (e *HTTPError) Error() string {
if e.Cause == nil {
return e.Detail
@i-mighty
i-mighty / cloudSettings
Last active June 12, 2022 05:23
Visual Studio Code Settings Sync Gist
{"lastUpload":"2021-07-28T18:41:31.661Z","extensionVersion":"v3.4.3"}