From cab0cd46714ad5af5ca68c1d57efa88567ab7064 Mon Sep 17 00:00:00 2001 From: James DeFelice Date: Thu, 23 Aug 2018 17:48:58 +0000 Subject: [PATCH] options: PrefixUnsafe --- options.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/options.go b/options.go index ef95bb8..b0281f7 100644 --- a/options.go +++ b/options.go @@ -113,6 +113,21 @@ func Prefix(p string) Option { }) } +// PrefixUnsafe appends the prefix that will be used in every bucket name. +// This func is "unsafe" because it doesn't attempt to normalize the prepend +// of the prefix by ensuring only a single separator character exists +// between the prefix and the suffix. Instead the onus for this check is +// placed upon the caller. This allows for prefixes to be added WITHOUT the +// automatic insertion of separator characters. +// +// Note that when used in cloned, the prefix of the parent Client is not +// replaced but is prepended to the given prefix. +func PrefixUnsafe(p string) Option { + return Option(func(c *config) { + c.Client.Prefix += p + }) +} + // TagFormat represents the format of tags sent by a Client. type TagFormat uint8