Skip to content

Instantly share code, notes, and snippets.

@jjmalina
Created December 4, 2013 15:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jjmalina/7789415 to your computer and use it in GitHub Desktop.
Save jjmalina/7789415 to your computer and use it in GitHub Desktop.
make-logs
//
// generates lines of json and sends them to stdout
// usage:
// make-logs -n 10000 | write-or-delete-logs mybucket
package main
import (
"encoding/json"
"flag"
"fmt"
"github.com/nu7hatch/gouuid"
"math/rand"
)
type Log struct {
Id string
Payload string
}
func main() {
var nlogs = flag.Int("n", 10000, "The number of logs to create")
flag.Parse()
ipsum := []string{
"Exercitation cow laboris, kielbasa commodo ea fatback incididunt ribeye culpa pork flank sirloin. Ad ball tip meatball tri-tip, jerky et shoulder leberkas sirloin est cillum. Chicken meatloaf ball tip id fatback ad bacon spare ribs cupidatat enim laborum shank. Nulla capicola do anim laborum.",
"Quis hamburger velit in cillum chuck consequat commodo. Doner shoulder est eiusmod magna. Pariatur minim frankfurter, meatball duis fatback ham bacon id consequat ut commodo mollit. Deserunt labore pork tenderloin, dolor ex venison kielbasa turducken kevin. Flank minim pig aliqua dolore. Shank mollit excepteur ribeye, corned beef shoulder meatball labore cupidatat tri-tip hamburger nisi kevin tongue nostrud.",
"Capicola hamburger nostrud, ground round tenderloin pork irure ad. Venison aliqua ham anim commodo hamburger. Ball tip quis nostrud voluptate meatloaf kevin short loin kielbasa dolore sint enim. Kielbasa pastrami spare ribs officia qui, capicola sausage bacon ham hock ut in andouille ex. Commodo pork chop tenderloin, laborum turkey kevin brisket tongue eiusmod duis nostrud tempor ribeye biltong quis.",
"Shoulder deserunt sunt, eiusmod magna meatloaf andouille t-bone flank ullamco beef. Chuck salami tail leberkas pork eu flank beef ribs qui pastrami sausage. Tenderloin hamburger eiusmod cow spare ribs ullamco, labore jerky bacon sausage. Pastrami andouille dolore pork loin occaecat. Ball tip pork in meatball tempor.",
"Pork belly sunt in occaecat dolore frankfurter mollit elit leberkas nisi sint filet mignon prosciutto adipisicing. T-bone fugiat irure voluptate pork loin shank ea capicola boudin. Dolore sausage pork belly, officia ball tip turducken do venison leberkas tempor spare ribs. Short loin elit reprehenderit mollit pancetta. Minim beef ribs ut ut consectetur brisket spare ribs excepteur chuck pariatur est shoulder drumstick short loin aliqua. Spare ribs strip steak esse pig, incididunt andouille biltong. Filet mignon id tail voluptate venison.",
}
for i := 0; i < *nlogs; i++ {
u4, err := uuid.NewV4()
if err != nil {
continue
}
log := &Log{
Id: u4.String(),
Payload: ipsum[rand.Intn(len(ipsum))],
}
data, err := json.Marshal(*log)
if err == nil {
fmt.Println(string(data))
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment