Skip to content

Instantly share code, notes, and snippets.

@dpinela
dpinela / trymflg.patch
Last active July 7, 2019 12:02
Conversion of github.com/dpinela/mflg to use try
diff --git a/application.go b/application.go
index 0dd4012..f689a24 100644
--- a/application.go
+++ b/application.go
@@ -118,15 +118,11 @@ func (app *application) navigateTo(where string) error {
if app.filename != "" {
filename = filepath.Join(filepath.Dir(app.filename), filename)
} else {
- if filename, err = filepath.Abs(filename); err != nil {
- return err
@dpinela
dpinela / govarargs.md
Created January 24, 2018 11:27
Go experience report about issues with variadic functions

Counter-intuitive behaviour of Go variadic functions

In Go, we can define functions that take a variable number of arguments, by defining a "rest" argument. When calling such a function, one can pass the elements of a slice as the "variadic" arguments with the ... syntax, as in:

elems := []string{"usr", "local", "bin"}
p := filepath.Join(elems...)

However, this only works if the slice:

  1. lines up exactly with the "rest" argument