Last active
August 29, 2015 14:04
-
-
Save bltavares/9dd8ebfd765d1e454444 to your computer and use it in GitHub Desktop.
Timestamper
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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