From e4ccdaae0fefcaf57c1c49a29b1e058bfa1f2443 Mon Sep 17 00:00:00 2001 From: metalbreeze Date: Wed, 16 Feb 2022 08:56:53 +0800 Subject: [PATCH 1/4] Update user.go --- user.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/user.go b/user.go index 3e64e42c..ce43fb69 100644 --- a/user.go +++ b/user.go @@ -228,6 +228,30 @@ func WithInactive(inactive bool) userSearchF { } } +// WithUsername sets the username to search +func WithUsername (username string) userSearchF { + return func(s userSearch) userSearch { + s = append(s, userSearchParam{name: "username", value: fmt.Sprintf("%s", username)}) + return s + } +} + +// WithAccountId sets the account id to search +func WithAccountId (accountId string) userSearchF { + return func(s userSearch) userSearch { + s = append(s, userSearchParam{name: "accountId", value: fmt.Sprintf("%s", accountId)}) + return s + } +} + +// WithProperty sets the property (Property keys are specified by path) to search +func WithProperty (property string) userSearchF { + return func(s userSearch) userSearch { + s = append(s, userSearchParam{name: "property", value: fmt.Sprintf("%s", property)}) + return s + } +} + // FindWithContext searches for user info from Jira: // It can find users by email or display name using the query parameter // From 2d289a213844c39bb7fef16bb85237cc1c7d01b8 Mon Sep 17 00:00:00 2001 From: metalbreeze Date: Sat, 19 Feb 2022 09:27:54 +0000 Subject: [PATCH 2/4] go fmt file --- user.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/user.go b/user.go index ce43fb69..80eb0561 100644 --- a/user.go +++ b/user.go @@ -229,7 +229,7 @@ func WithInactive(inactive bool) userSearchF { } // WithUsername sets the username to search -func WithUsername (username string) userSearchF { +func WithUsername(username string) userSearchF { return func(s userSearch) userSearch { s = append(s, userSearchParam{name: "username", value: fmt.Sprintf("%s", username)}) return s @@ -237,15 +237,15 @@ func WithUsername (username string) userSearchF { } // WithAccountId sets the account id to search -func WithAccountId (accountId string) userSearchF { +func WithAccountId(accountId string) userSearchF { return func(s userSearch) userSearch { s = append(s, userSearchParam{name: "accountId", value: fmt.Sprintf("%s", accountId)}) return s } } -// WithProperty sets the property (Property keys are specified by path) to search -func WithProperty (property string) userSearchF { +// WithProperty sets the property (Property keys are specified by path) to search +func WithProperty(property string) userSearchF { return func(s userSearch) userSearch { s = append(s, userSearchParam{name: "property", value: fmt.Sprintf("%s", property)}) return s From 7d11e4867e590107af8b6c65ccf1eed1f833be2a Mon Sep 17 00:00:00 2001 From: metalbreeze Date: Sat, 19 Feb 2022 20:28:40 +0000 Subject: [PATCH 3/4] remote extra Sprintf according error msg. --- user.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/user.go b/user.go index 80eb0561..38963b94 100644 --- a/user.go +++ b/user.go @@ -231,7 +231,7 @@ func WithInactive(inactive bool) userSearchF { // WithUsername sets the username to search func WithUsername(username string) userSearchF { return func(s userSearch) userSearch { - s = append(s, userSearchParam{name: "username", value: fmt.Sprintf("%s", username)}) + s = append(s, userSearchParam{name: "username", value: username}) return s } } @@ -239,7 +239,7 @@ func WithUsername(username string) userSearchF { // WithAccountId sets the account id to search func WithAccountId(accountId string) userSearchF { return func(s userSearch) userSearch { - s = append(s, userSearchParam{name: "accountId", value: fmt.Sprintf("%s", accountId)}) + s = append(s, userSearchParam{name: "accountId", value: accountId}) return s } } @@ -247,7 +247,7 @@ func WithAccountId(accountId string) userSearchF { // WithProperty sets the property (Property keys are specified by path) to search func WithProperty(property string) userSearchF { return func(s userSearch) userSearch { - s = append(s, userSearchParam{name: "property", value: fmt.Sprintf("%s", property)}) + s = append(s, userSearchParam{name: "property", property}) return s } } From 9b0f9ad519a75ebbc14157871db9cfa9fa2b5ffb Mon Sep 17 00:00:00 2001 From: metalbreeze Date: Sun, 20 Feb 2022 04:33:22 +0000 Subject: [PATCH 4/4] fix the error: mixture of field:value and value elements in struct literal --- user.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user.go b/user.go index 38963b94..5d68c167 100644 --- a/user.go +++ b/user.go @@ -247,7 +247,7 @@ func WithAccountId(accountId string) userSearchF { // WithProperty sets the property (Property keys are specified by path) to search func WithProperty(property string) userSearchF { return func(s userSearch) userSearch { - s = append(s, userSearchParam{name: "property", property}) + s = append(s, userSearchParam{name: "property", value: property}) return s } }