From d18c4022d277dd45ffc388b8f3868a42ab9592ad Mon Sep 17 00:00:00 2001
From: lassulus <lass@lassul.us>
Date: Mon, 1 May 2017 12:19:51 +0200
Subject: [PATCH] goify: init

---
 krebs/5pkgs/goify/default.nix | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
 create mode 100644 krebs/5pkgs/goify/default.nix

diff --git a/krebs/5pkgs/goify/default.nix b/krebs/5pkgs/goify/default.nix
new file mode 100644
index 000000000..e2849b5c7
--- /dev/null
+++ b/krebs/5pkgs/goify/default.nix
@@ -0,0 +1,17 @@
+{ pkgs, ... }:
+
+pkgs.writeDashBin "goify" ''
+  set -euf
+
+  GO_HOST=''${GO_HOST:-go}
+
+  while read line; do
+    echo "$line" | sed -E 's|https?://\S*|\n&\n|g' | while read word; do
+      if echo "$word" | grep -Eq ^https?:; then
+        ${pkgs.curl}/bin/curl -Ss -F uri="$word" http://"$GO_HOST" | tr -d '\r'
+      else
+        echo "$word";
+      fi;
+    done | sed '/^$/d' | tr '\n' ' '; echo;
+  done
+''