Skip to content

Instantly share code, notes, and snippets.

@gorsuch
Created December 1, 2011 18:37
  • Star 51 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save gorsuch/1418850 to your computer and use it in GitHub Desktop.
clojure uuid
(defn uuid [] (str (java.util.UUID/randomUUID)))
@Profpatsch
Copy link

There should be a pure Clojure library for UUIDs to be compatible across different implementations.

@xpe
Copy link

xpe commented Feb 1, 2014

FYI: "There are four different basic types of UUIDs: time-based, DCE security, name-based, and randomly generated UUIDs. These types have a version value of 1, 2, 3 and 4, respectively." http://docs.oracle.com/javase/7/docs/api/java/util/UUID.html#randomUUID()

@Kungi
Copy link

Kungi commented Feb 3, 2014

Thank you :-).

@Deepakdubey90
Copy link

Thank you

@escherize
Copy link

Maybe I should memorize this, but I always just google 'clojure uuid' instead. Thanks. 👍

@niquola
Copy link

niquola commented Mar 10, 2015

👍 me too

@escherize
Copy link

Also, just noticed this library: http://danlentz.github.io/clj-uuid/ Hope it helps :)

@dillonforrest
Copy link

👍

Copy link

ghost commented Sep 30, 2015

good

@spiffytech
Copy link

👍

@blackawa
Copy link

👍

@kenfehling
Copy link

Is it weird/bad that I like this form instead?
(def uuid #(str (java.util.UUID/randomUUID)))

@camdez
Copy link

camdez commented Aug 28, 2017

@kenfehling It's not particularly weird or bad, but one small downside is that the function will lack the :arglists metadata the way you've written it (try running (:arglists (meta #'uuid))), which some development tooling might rely on to show you how to call the function.

@carbon-hvze
Copy link

thanks!

@aarkerio
Copy link

aarkerio commented Mar 4, 2020

¡Hartas gracias!

@siddharthjain-in
Copy link

thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment