Skip to content

Commit f73e734

Browse files
strklunny
authored andcommitted
Run "make fmt" with go-1.6 (#1333)
1 parent 888dee3 commit f73e734

File tree

15 files changed

+62
-67
lines changed

15 files changed

+62
-67
lines changed

integrations/signup_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ import (
1212
)
1313

1414
var signupFormSample map[string][]string = map[string][]string{
15-
"Name": []string{"tester"},
16-
"Email": []string{"[email protected]"},
17-
"Passwd": []string{"12345678"},
15+
"Name": {"tester"},
16+
"Email": {"[email protected]"},
17+
"Passwd": {"12345678"},
1818
}
1919

2020
func signup(t *utils.T) error {

models/issue_test.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,10 @@ func TestGetParticipantsByIssueID(t *testing.T) {
6767
checkPartecipants := func(issueID int64, userIDs []int) {
6868
partecipants, err := GetParticipantsByIssueID(issueID)
6969
if assert.NoError(t, err) {
70-
partecipantsIDs := make([]int,len(partecipants))
71-
for i,u := range partecipants { partecipantsIDs[i] = int(u.ID) }
70+
partecipantsIDs := make([]int, len(partecipants))
71+
for i, u := range partecipants {
72+
partecipantsIDs[i] = int(u.ID)
73+
}
7274
sort.Ints(partecipantsIDs)
7375
sort.Ints(userIDs)
7476
assert.Equal(t, userIDs, partecipantsIDs)
@@ -79,6 +81,6 @@ func TestGetParticipantsByIssueID(t *testing.T) {
7981
// User 1 is issue1 poster (see fixtures/issue.yml)
8082
// User 2 only labeled issue1 (see fixtures/comment.yml)
8183
// Users 3 and 5 made actual comments (see fixtures/comment.yml)
82-
checkPartecipants(1, []int{3,5})
84+
checkPartecipants(1, []int{3, 5})
8385

8486
}

models/migrations/v23.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,11 @@ import (
1212

1313
// UserOpenID is the list of all OpenID identities of a user.
1414
type UserOpenID struct {
15-
ID int64 `xorm:"pk autoincr"`
16-
UID int64 `xorm:"INDEX NOT NULL"`
17-
URI string `xorm:"UNIQUE NOT NULL"`
15+
ID int64 `xorm:"pk autoincr"`
16+
UID int64 `xorm:"INDEX NOT NULL"`
17+
URI string `xorm:"UNIQUE NOT NULL"`
1818
}
1919

20-
2120
func addUserOpenID(x *xorm.Engine) error {
2221
if err := x.Sync2(new(UserOpenID)); err != nil {
2322
return fmt.Errorf("Sync2: %v", err)

models/org_team.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ func (t *Team) removeRepository(e Engine, repo *Repository, recalculate bool) (e
143143
if err != nil {
144144
return fmt.Errorf("getTeamUsersByTeamID: %v", err)
145145
}
146-
for _, teamUser:= range teamUsers {
146+
for _, teamUser := range teamUsers {
147147
has, err := hasAccess(e, teamUser.UID, repo, AccessModeRead)
148148
if err != nil {
149149
return err

models/user_follow.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,3 @@ func UnfollowUser(userID, followID int64) (err error) {
6868
}
6969
return sess.Commit()
7070
}
71-

models/user_openid.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ var (
1818

1919
// UserOpenID is the list of all OpenID identities of a user.
2020
type UserOpenID struct {
21-
ID int64 `xorm:"pk autoincr"`
22-
UID int64 `xorm:"INDEX NOT NULL"`
23-
URI string `xorm:"UNIQUE NOT NULL"`
24-
Show bool `xorm:"DEFAULT false"`
21+
ID int64 `xorm:"pk autoincr"`
22+
UID int64 `xorm:"INDEX NOT NULL"`
23+
URI string `xorm:"UNIQUE NOT NULL"`
24+
Show bool `xorm:"DEFAULT false"`
2525
}
2626

2727
// GetUserOpenIDs returns all openid addresses that belongs to given user.
@@ -122,4 +122,3 @@ func GetUserByOpenID(uri string) (*User, error) {
122122

123123
return nil, ErrUserNotExist{0, uri, 0}
124124
}
125-

models/user_openid_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,14 @@ func TestGetUserByOpenID(t *testing.T) {
5252
func TestToggleUserOpenIDVisibility(t *testing.T) {
5353
assert.NoError(t, PrepareTestDatabase())
5454
oids, err := GetUserOpenIDs(int64(2))
55-
if ! assert.NoError(t, err) {
55+
if !assert.NoError(t, err) {
5656
return
5757
}
5858
assert.Len(t, oids, 1)
5959
assert.True(t, oids[0].Show)
6060

6161
err = ToggleUserOpenIDVisibility(oids[0].ID)
62-
if ! assert.NoError(t, err) {
62+
if !assert.NoError(t, err) {
6363
return
6464
}
6565

@@ -69,12 +69,12 @@ func TestToggleUserOpenIDVisibility(t *testing.T) {
6969
assert.False(t, oids[0].Show)
7070
}
7171
err = ToggleUserOpenIDVisibility(oids[0].ID)
72-
if ! assert.NoError(t, err) {
72+
if !assert.NoError(t, err) {
7373
return
7474
}
7575

7676
oids, err = GetUserOpenIDs(int64(2))
77-
if ! assert.NoError(t, err) {
77+
if !assert.NoError(t, err) {
7878
return
7979
}
8080
assert.Len(t, oids, 1)

modules/auth/openid/discovery_cache.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ type timedDiscoveredInfo struct {
1818

1919
type timedDiscoveryCache struct {
2020
cache map[string]timedDiscoveredInfo
21-
ttl time.Duration
21+
ttl time.Duration
2222
mutex *sync.Mutex
2323
}
2424

@@ -56,4 +56,3 @@ func (s *timedDiscoveryCache) Get(id string) openid.DiscoveredInfo {
5656
}
5757
return nil
5858
}
59-

modules/auth/openid/discovery_cache_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ import (
99
"time"
1010
)
1111

12-
type testDiscoveredInfo struct {}
12+
type testDiscoveredInfo struct{}
13+
1314
func (s *testDiscoveredInfo) ClaimedID() string {
1415
return "claimedID"
1516
}
@@ -21,7 +22,7 @@ func (s *testDiscoveredInfo) OpLocalID() string {
2122
}
2223

2324
func TestTimedDiscoveryCache(t *testing.T) {
24-
dc := newTimedDiscoveryCache(1*time.Second)
25+
dc := newTimedDiscoveryCache(1 * time.Second)
2526

2627
// Put some initial values
2728
dc.Put("foo", &testDiscoveredInfo{}) //openid.opEndpoint: "a", openid.opLocalID: "b", openid.claimedID: "c"})

modules/auth/openid/openid.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ import (
1717
// least
1818
// the nonceStore between them.
1919
var nonceStore = openid.NewSimpleNonceStore()
20-
var discoveryCache = newTimedDiscoveryCache(24*time.Hour)
21-
20+
var discoveryCache = newTimedDiscoveryCache(24 * time.Hour)
2221

2322
// Verify handles response from OpenID provider
2423
func Verify(fullURL string) (id string, err error) {
@@ -34,4 +33,3 @@ func Normalize(url string) (id string, err error) {
3433
func RedirectURL(id, callbackURL, realm string) (string, error) {
3534
return openid.RedirectURL(id, callbackURL, realm)
3635
}
37-

modules/auth/user_form.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ func (f *ChangePasswordForm) Validate(ctx *macaron.Context, errs binding.Errors)
155155

156156
// AddOpenIDForm is for changing openid uri
157157
type AddOpenIDForm struct {
158-
Openid string `binding:"Required;MaxSize(256)"`
158+
Openid string `binding:"Required;MaxSize(256)"`
159159
}
160160

161161
// Validate validates the fields

modules/auth/user_form_auth_openid.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,9 @@ import (
99
"gopkg.in/macaron.v1"
1010
)
1111

12-
1312
// SignInOpenIDForm form for signing in with OpenID
1413
type SignInOpenIDForm struct {
15-
Openid string `binding:"Required;MaxSize(256)"`
14+
Openid string `binding:"Required;MaxSize(256)"`
1615
Remember bool
1716
}
1817

@@ -42,4 +41,3 @@ type ConnectOpenIDForm struct {
4241
func (f *ConnectOpenIDForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
4342
return validate(errs, ctx.Data, f, ctx.Locale)
4443
}
45-

modules/setting/setting.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -762,14 +762,14 @@ please consider changing to GITEA_CUSTOM`)
762762
EnableOpenIDSignIn = sec.Key("ENABLE_OPENID_SIGNIN").MustBool(true)
763763
EnableOpenIDSignUp = sec.Key("ENABLE_OPENID_SIGNUP").MustBool(true)
764764
pats := sec.Key("WHITELISTED_URIS").Strings(" ")
765-
if ( len(pats) != 0 ) {
765+
if len(pats) != 0 {
766766
OpenIDWhitelist = make([]*regexp.Regexp, len(pats))
767767
for i, p := range pats {
768768
OpenIDWhitelist[i] = regexp.MustCompilePOSIX(p)
769769
}
770770
}
771771
pats = sec.Key("BLACKLISTED_URIS").Strings(" ")
772-
if ( len(pats) != 0 ) {
772+
if len(pats) != 0 {
773773
OpenIDBlacklist = make([]*regexp.Regexp, len(pats))
774774
for i, p := range pats {
775775
OpenIDBlacklist[i] = regexp.MustCompilePOSIX(p)

routers/user/auth_openid.go

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -102,23 +102,24 @@ func SignInOpenIDPost(ctx *context.Context, form auth.SignInOpenIDForm) {
102102
id, err := openid.Normalize(form.Openid)
103103
if err != nil {
104104
ctx.RenderWithErr(err.Error(), tplSignInOpenID, &form)
105-
return;
105+
return
106106
}
107107
form.Openid = id
108108

109109
log.Trace("OpenID uri: " + id)
110110

111-
err = allowedOpenIDURI(id); if err != nil {
111+
err = allowedOpenIDURI(id)
112+
if err != nil {
112113
ctx.RenderWithErr(err.Error(), tplSignInOpenID, &form)
113-
return;
114+
return
114115
}
115116

116117
redirectTo := setting.AppURL + "user/login/openid"
117118
url, err := openid.RedirectURL(id, redirectTo, setting.AppURL)
118-
if err != nil {
119+
if err != nil {
119120
ctx.RenderWithErr(err.Error(), tplSignInOpenID, &form)
120-
return;
121-
}
121+
return
122+
}
122123

123124
// Request optional nickname and email info
124125
// NOTE: change to `openid.sreg.required` to require it
@@ -134,10 +135,10 @@ func SignInOpenIDPost(ctx *context.Context, form auth.SignInOpenIDForm) {
134135
// signInOpenIDVerify handles response from OpenID provider
135136
func signInOpenIDVerify(ctx *context.Context) {
136137

137-
log.Trace("Incoming call to: " + ctx.Req.Request.URL.String())
138+
log.Trace("Incoming call to: " + ctx.Req.Request.URL.String())
138139

139-
fullURL := setting.AppURL + ctx.Req.Request.URL.String()[1:]
140-
log.Trace("Full URL: " + fullURL)
140+
fullURL := setting.AppURL + ctx.Req.Request.URL.String()[1:]
141+
log.Trace("Full URL: " + fullURL)
141142

142143
var id, err = openid.Verify(fullURL)
143144
if err != nil {
@@ -154,7 +155,7 @@ func signInOpenIDVerify(ctx *context.Context) {
154155

155156
u, _ := models.GetUserByOpenID(id)
156157
if err != nil {
157-
if ! models.IsErrUserNotExist(err) {
158+
if !models.IsErrUserNotExist(err) {
158159
ctx.RenderWithErr(err.Error(), tplSignInOpenID, &auth.SignInOpenIDForm{
159160
Openid: id,
160161
})
@@ -188,12 +189,12 @@ func signInOpenIDVerify(ctx *context.Context) {
188189
email := values.Get("openid.sreg.email")
189190
nickname := values.Get("openid.sreg.nickname")
190191

191-
log.Trace("User has email=" + email + " and nickname=" + nickname)
192+
log.Trace("User has email=" + email + " and nickname=" + nickname)
192193

193194
if email != "" {
194195
u, _ = models.GetUserByEmail(email)
195196
if err != nil {
196-
if ! models.IsErrUserNotExist(err) {
197+
if !models.IsErrUserNotExist(err) {
197198
ctx.RenderWithErr(err.Error(), tplSignInOpenID, &auth.SignInOpenIDForm{
198199
Openid: id,
199200
})
@@ -208,7 +209,7 @@ func signInOpenIDVerify(ctx *context.Context) {
208209
if u == nil && nickname != "" {
209210
u, _ = models.GetUserByName(nickname)
210211
if err != nil {
211-
if ! models.IsErrUserNotExist(err) {
212+
if !models.IsErrUserNotExist(err) {
212213
ctx.RenderWithErr(err.Error(), tplSignInOpenID, &auth.SignInOpenIDForm{
213214
Openid: id,
214215
})
@@ -230,7 +231,7 @@ func signInOpenIDVerify(ctx *context.Context) {
230231

231232
ctx.Session.Set("openid_determined_username", nickname)
232233

233-
if u != nil || ! setting.EnableOpenIDSignUp {
234+
if u != nil || !setting.EnableOpenIDSignUp {
234235
ctx.Redirect(setting.AppSubURL + "/user/openid/connect")
235236
} else {
236237
ctx.Redirect(setting.AppSubURL + "/user/openid/register")
@@ -280,7 +281,7 @@ func ConnectOpenIDPost(ctx *context.Context, form auth.ConnectOpenIDForm) {
280281
}
281282

282283
// add OpenID for the user
283-
userOID := &models.UserOpenID{UID:u.ID, URI:oid}
284+
userOID := &models.UserOpenID{UID: u.ID, URI: oid}
284285
if err = models.AddUserOpenID(userOID); err != nil {
285286
if models.IsErrOpenIDAlreadyUsed(err) {
286287
ctx.RenderWithErr(ctx.Tr("form.openid_been_used", oid), tplConnectOID, &form)
@@ -299,7 +300,7 @@ func ConnectOpenIDPost(ctx *context.Context, form auth.ConnectOpenIDForm) {
299300

300301
// RegisterOpenID shows a form to create a new user authenticated via an OpenID URI
301302
func RegisterOpenID(ctx *context.Context) {
302-
if ! setting.EnableOpenIDSignUp {
303+
if !setting.EnableOpenIDSignUp {
303304
ctx.Error(403)
304305
return
305306
}
@@ -327,7 +328,7 @@ func RegisterOpenID(ctx *context.Context) {
327328

328329
// RegisterOpenIDPost handles submission of a form to create a new user authenticated via an OpenID URI
329330
func RegisterOpenIDPost(ctx *context.Context, cpt *captcha.Captcha, form auth.SignUpOpenIDForm) {
330-
if ! setting.EnableOpenIDSignUp {
331+
if !setting.EnableOpenIDSignUp {
331332
ctx.Error(403)
332333
return
333334
}
@@ -351,7 +352,9 @@ func RegisterOpenIDPost(ctx *context.Context, cpt *captcha.Captcha, form auth.Si
351352
}
352353

353354
len := setting.MinPasswordLength
354-
if len < 256 { len = 256 }
355+
if len < 256 {
356+
len = 256
357+
}
355358
password, err := base.GetRandomString(len)
356359
if err != nil {
357360
ctx.RenderWithErr(err.Error(), tplSignUpOID, form)
@@ -387,7 +390,7 @@ func RegisterOpenIDPost(ctx *context.Context, cpt *captcha.Captcha, form auth.Si
387390
log.Trace("Account created: %s", u.Name)
388391

389392
// add OpenID for the user
390-
userOID := &models.UserOpenID{UID:u.ID, URI:oid}
393+
userOID := &models.UserOpenID{UID: u.ID, URI: oid}
391394
if err = models.AddUserOpenID(userOID); err != nil {
392395
if models.IsErrOpenIDAlreadyUsed(err) {
393396
ctx.RenderWithErr(ctx.Tr("form.openid_been_used", oid), tplSignUpOID, &form)

0 commit comments

Comments
 (0)