Skip to content

Instantly share code, notes, and snippets.

@bltavares
Last active August 29, 2015 14:04
Show Gist options
  • Save bltavares/9dd8ebfd765d1e454444 to your computer and use it in GitHub Desktop.
Save bltavares/9dd8ebfd765d1e454444 to your computer and use it in GitHub Desktop.
Timestamper
package main
import (
"bufio"
"fmt"
"os"
"time"
)
func main() {
reader := bufio.NewReader(os.Stdin)
for {
line, err := reader.ReadString('\n')
if err != nil {
break
}
fmt.Print(time.Now().UTC(), "|", line)
}
}
import System.IO (isEOF)
import Data.Time (getCurrentTime)
import Control.Monad (liftM2, unless)
stamp (x, y) = x ++ "|" ++ y
currentTime = fmap show getCurrentTime
main = isEOF >>= flip unless repl
where
input = liftM2 (,) currentTime getLine
repl = fmap stamp input >>= putStrLn >> main
extern crate time;
use std::io;
use time::now_utc;
fn main() {
for line in io::stdin().lines() {
print!("{}|{}", now_utc().rfc822z(), line.unwrap());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment