From 0966f43755003be381b27a602ae66202faab1812 Mon Sep 17 00:00:00 2001 From: Charles Iliya Krempeaux Date: Mon, 8 Nov 2021 15:08:49 -0800 Subject: [PATCH] initial commits --- id.go | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/id.go b/id.go index 961b566..605d189 100644 --- a/id.go +++ b/id.go @@ -39,6 +39,33 @@ func something(value uint64) ID { } } +// Parse parses the string contained in the input-variable ‘ximnotation’, and if it contains a valid xim-id (in xim-notation), then it returns it. +// +// If the value of the input-variable ‘ximnotation’ is not a valid (xim-notation) xim-id, then it returns the option-type value nothing. +// +// An example usage might be: +// +// var ximid string = "xi-558YtmR06wm" +// +// // ... +// +// var id xim.ID = xim.Parse(ximid) +// if xim.Nothing() == id { +// fmt.Fprintf(os.Stderr, "error: invalid xim-id — %q \n", ximid) +// return +// } +// +// fmt.Printf("SUCCESS! the xim-id is \n", id) +func Parse(ximnotation string) ID { + + value, successful := unserialize(ximnotation) + if !successful { + return Nothing() + } + + return something(value) +} + // Generate returns a new xim-id. // // Example usage: