Skip to content

Instantly share code, notes, and snippets.

View a3s7p's full-sized avatar
☸️

Anton a3s7p

☸️
View GitHub Profile
@a3s7p
a3s7p / error.go
Created November 23, 2019 16:38
go error monad
package main
import (
"errors"
"log"
)
type F func() error
func errCompose(pipeline ...F) (e error, ok bool) {
@a3s7p
a3s7p / gofmt.vim
Last active September 3, 2019 09:44
A complete, plugin-free method to gofmt code on write
" this reloads the file after formatting
" while preserving current view and undo history
function! GoFmtSave()
:undoj " do not create undo history entry
let l:oldx = getpos("'x") " save current x mark
let l:oldy = getpos("'y") " save current y mark
:norm! mxHmy " mark current position and top of screen
!gofmt -w % " call gofmt on the current file
:e " reload file