Skip to content

Instantly share code, notes, and snippets.

View avary's full-sized avatar

Abdulhafiz KAŞGARLI avary

View GitHub Profile
@avary
avary / update-golang.md
Created March 1, 2024 06:23 — forked from nikhita/update-golang.md
How to update the Go version

How to update the Go version

System: Debian/Ubuntu/Fedora. Might work for others as well.

1. Uninstall the exisiting version

As mentioned here, to update a go version you will first need to uninstall the original version.

To uninstall, delete the /usr/local/go directory by:

@avary
avary / folder_structure.md
Created February 12, 2024 06:17 — forked from ayoubzulfiqar/folder_structure.md
The Folder Structure for Every Golang Project

Go - The Ultimate Folder Structure

Organizing your Go (Golang) project's folder structure can help improve code readability, maintainability, and scalability. While there is no one-size-fits-all structure, here's a common folder structure for a Go project:

project-root/
    ├── cmd/
    │   ├── your-app-name/
    │   │   ├── main.go         # Application entry point
    │   │   └── ...             # Other application-specific files
@avary
avary / example.go
Created January 25, 2024 09:11 — forked from nd2408/example.go
fsnotify wrapper
logger := slog.New(slog.NewJSONHandler(os.Stdout, &slog.HandlerOptions{
AddSource: false,
Level: slog.LevelDebug,
}))
slog.SetDefault(logger)
watcher, err := watcher.New(logger)
defer watcher.Shutdown()
err = watcher.Watch("/home/user", func(e watcher.Event) error {
@avary
avary / benchmarks_test.go
Created January 9, 2024 06:08 — forked from alaindet/benchmarks_test.go
Go slice mapping concurrently
package main
import "testing"
func BenchmarkConcMap100(b *testing.B) {
b.StopTimer()
input := createRange(100)
output := make([]int, 0, len(input))
b.StartTimer()
@avary
avary / CustomResponseWriter.go
Created January 9, 2024 05:51 — forked from prakashpandey/CustomResponseWriter.go
Implement custom http.ResponseWriter in golang
package main
import (
"fmt"
"net/http"
)
type CustomResponseWriter struct {
body []byte
statusCode int
@avary
avary / gin-secure-https.go
Created December 13, 2023 09:30 — forked from kenng/gin-secure-https.go
redirect gin http to https using unrolled/secure
// gin will throw following for the first time due to secure initiate a http.Redirect but gin is unaware of it
// [GIN-debug] [WARNING] Headers were already written. Wanted to override status code 301 with 200
package main
import (
"github.com/gin-gonic/gin"
"github.com/unrolled/secure"
)
Source link: https://stackoverflow.com/questions/31374085/installing-adb-on-macos
# Option 1 - Using Homebrew
This is the easiest way and will provide automatic updates.
1. Install [homebrew](http://brew.sh/)
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
2. Install adb
@avary
avary / aliases
Last active September 27, 2023 08:55
some aliases for macos/zhs
# pull/update multi git repos,
multipull0='ls | xargs -I{} git -C {} pull --ff'
# for laravel
pa='php artisan serv'
pad='php artisan dump-autoload'
# i use high sierra and macport cuz brew dosnt always work on high sierra
sqla='sudo port unload mysql8-server'
sqlu='sudo port load mysql8-server'
@avary
avary / convert_repo.sh
Created August 18, 2023 07:08 — forked from iserko/convert_repo.sh
Shell script for easily joining multiple GIT repositories into a single repository by rewriting the GIT history
#!/bin/bash
###########
# ./convert_repo.sh
# Author: Igor Serko <[email protected]>
# Description: Allows the user to join multiple git repositories under one single repository
# Procedure: Using git filter-branch we rewrite the history of every repo
# example of current tree
# -- REPOONE
# |-- repoone files
# -- REPOTWO
@avary
avary / config.toml
Created August 17, 2023 07:59 — forked from ghiden/config.toml
Load TOML config and pick environment from a environmental variable in Go
[dev]
url = "http://dev.example.com"
username = "dev.account"
password = "devdev"
[test]
url = "http://test.example.com"
username = "test.account"
password = "testtest"