Skip to content

Instantly share code, notes, and snippets.

@rcy
Created February 28, 2026 23:53
Show Gist options
  • Select an option

  • Save rcy/21a8dfe3bf2c3e8d3d167d819344759d to your computer and use it in GitHub Desktop.

Select an option

Save rcy/21a8dfe3bf2c3e8d3d167d819344759d to your computer and use it in GitHub Desktop.
(defvar go-scratch-base-directory "~/personal/go-scratch")
(defun go-scratch ()
(interactive)
(let ((dir (format "%s/%s" go-scratch-base-directory (format-time-string "%Y%m%d-%H%M"))))
(make-directory dir t)
(find-file (file-name-concat dir "main.go"))
(when (eq (point-min) (point-max))
(insert "// -*- compile-command: \"go run main.go\"; -*-
package main
import (
\"fmt\"
)
func main() {
fmt.Println(\"Hello, scratch\")
}
")
(hack-local-variables))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment