From 981632248f712c4f5b9283275a56f359fb2bd603 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B5=D0=B9=20=D0=92=D0=BE?= =?UTF-8?q?=D0=BB=D0=B5=D0=B3=D0=BE=D0=B2?= Date: Fri, 10 Sep 2021 09:29:31 +0300 Subject: [PATCH] #1210 add WithToken for change token --- gitlab.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/gitlab.go b/gitlab.go index 141510e58..41fdc303f 100644 --- a/gitlab.go +++ b/gitlab.go @@ -834,3 +834,14 @@ func parseError(raw interface{}) string { return fmt.Sprintf("failed to parse unexpected error type: %T", raw) } } + +// WithToken сhanges the token, but does not change the authorization method. +// For change authorization method create new Client. +func (c *Client) WithToken(token string) *Client { + c.tokenLock.Lock() + defer c.tokenLock.Unlock() + + c.token = token + + return c +}