From 1d814a0d7bd07fb5ad07bf7204e796a79aa4895b Mon Sep 17 00:00:00 2001 From: Blake Mizerany Date: Wed, 23 Nov 2011 20:16:28 -0800 Subject: [PATCH] init --- .gitignore | 7 +++++++ Makefile | 14 ++++++++++++++ README.md | 42 ++++++++++++++++++++++++++++++++++++++++++ main.go | 32 ++++++++++++++++++++++++++++++++ 4 files changed, 95 insertions(+) create mode 100644 .gitignore create mode 100644 Makefile create mode 100644 README.md create mode 100644 main.go diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7ed2fc1 --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +*.[568] +[568].out +_obj +_test* +noeq +*.gz +*.swp diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..5387c63 --- /dev/null +++ b/Makefile @@ -0,0 +1,14 @@ +# figure out what GOROOT is supposed to be +GOROOT ?= $(shell printf 't:;@echo $$(GOROOT)\n' | gomake -f -) +include $(GOROOT)/src/Make.inc + +VERSION=$(shell git describe --tags) + +TARG=noeq +GOFILES=\ + main.go\ + +include $(GOROOT)/src/Make.cmd + +tar: clean $(TARG) + tar -czf $(TARG)-$(VERSION)-$(GOOS)-$(GOARCH).tar.gz $(TARG) README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..69c6bfe --- /dev/null +++ b/README.md @@ -0,0 +1,42 @@ +# noeq - A command line client for noeqd + +## Install + +You can download the binary [here](http://github.com/bmizerany/noeq/downloads) + +Or clone this repo and build with Go weekly/weekly.2011-11-18 or later. + +## Use + + $ goflake -h + Usage of goflake: + -a="127.0.0.1:4444": the goflake address + -c=1: the number of ids to generate + $ goflake + 140193482529570816 + +## See Also + + + +## LICENSE + +Copyright (C) 2011 by Blake Mizerany ([@bmizerany](http://twitter.com/bmizerany) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/main.go b/main.go new file mode 100644 index 0000000..5f92697 --- /dev/null +++ b/main.go @@ -0,0 +1,32 @@ +package main + +import ( + "flag" + "fmt" + "github.com/bmizerany/noeq.go" + "log" +) + +// Flags +var ( + addr = flag.String("a", "127.0.0.1:4444", "the noeq address") + c = flag.Int("c", 1, "the number of ids to generate (1-255)") +) + +func main() { + flag.Parse() + + ne, err := noeq.New(*addr) + if err != nil { + log.Fatal(err) + } + + ids, err := ne.Gen(uint8(*c)) + if err != nil { + log.Fatal(err) + } + + for _, id := range ids { + fmt.Println(id) + } +}