Skip to content
This repository was archived by the owner on Sep 11, 2020. It is now read-only.

Commit 7b0f65f

Browse files
ferhatelmasmcuadros
authored andcommitted
gofmt simplify (#111)
1 parent 0ff9ef2 commit 7b0f65f

File tree

13 files changed

+188
-189
lines changed

13 files changed

+188
-189
lines changed

clients/ssh/git_upload_pack.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ func (f *fetchSession) Close() (err error) {
309309

310310
func (s *GitUploadPackService) getCommand() string {
311311
directory := s.endpoint.Path
312-
directory = directory[1:len(directory)]
312+
directory = directory[1:]
313313

314314
return fmt.Sprintf("git-upload-pack '%s'", directory)
315315
}

commit_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,14 @@ func (s *SuiteCommit) TestCommitEncodeDecodeIdempotent(c *C) {
6868
ts, err := time.Parse(time.RFC3339, "2006-01-02T15:04:05-07:00")
6969
c.Assert(err, IsNil)
7070
commits := []*Commit{
71-
&Commit{
71+
{
7272
Author: Signature{Name: "Foo", Email: "[email protected]", When: ts},
7373
Committer: Signature{Name: "Bar", Email: "[email protected]", When: ts},
7474
Message: "Message\n\nFoo\nBar\nWith trailing blank lines\n\n",
7575
tree: core.NewHash("f000000000000000000000000000000000000001"),
7676
parents: []core.Hash{core.NewHash("f000000000000000000000000000000000000002")},
7777
},
78-
&Commit{
78+
{
7979
Author: Signature{Name: "Foo", Email: "[email protected]", When: ts},
8080
Committer: Signature{Name: "Bar", Email: "[email protected]", When: ts},
8181
Message: "Message\n\nFoo\nBar\nWith no trailing blank lines",

config/refspec.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func (s RefSpec) IsValid() bool {
3535
}
3636

3737
ws := strings.Count(spec[0:sep], refSpecWildcard)
38-
wd := strings.Count(spec[sep+1:len(spec)], refSpecWildcard)
38+
wd := strings.Count(spec[sep+1:], refSpecWildcard)
3939
return ws == wd && ws < 2 && wd < 2
4040
}
4141

@@ -95,7 +95,7 @@ func (s RefSpec) matchGlob(n core.ReferenceName) bool {
9595
func (s RefSpec) Dst(n core.ReferenceName) core.ReferenceName {
9696
spec := string(s)
9797
start := strings.Index(spec, refSpecSeparator) + 1
98-
dst := spec[start:len(spec)]
98+
dst := spec[start:]
9999
src := s.Src()
100100

101101
if !s.IsWildcard() {
@@ -107,7 +107,7 @@ func (s RefSpec) Dst(n core.ReferenceName) core.ReferenceName {
107107
wd := strings.Index(dst, refSpecWildcard)
108108
match := name[ws : len(name)-(len(src)-(ws+1))]
109109

110-
return core.ReferenceName(dst[0:wd] + match + dst[wd+1:len(dst)])
110+
return core.ReferenceName(dst[0:wd] + match + dst[wd+1:])
111111
}
112112

113113
func (s RefSpec) String() string {

cshared/auth_method_cshared.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,12 @@ func c_ParseAuthorizedKey(in []byte) (uint64, *C.char, *C.char, *C.char, int, in
8787
pkey, comment, options, rest, err := ssh.ParseAuthorizedKey(in)
8888
if err != nil {
8989
return IH, nil, nil, nil, 0, ErrorCodeInternal,
90-
C.CString(err.Error())
90+
C.CString(err.Error())
9191
}
9292
pkey_handle := RegisterObject(&pkey)
9393
mopt := strings.Join(options, "\xff")
9494
return uint64(pkey_handle), C.CString(comment), C.CString(mopt),
95-
C.CString(string(rest)), len(rest), ErrorCodeSuccess, nil
95+
C.CString(string(rest)), len(rest), ErrorCodeSuccess, nil
9696
}
9797

9898
//export c_ssh_Password_New
@@ -189,4 +189,4 @@ func c_ssh_PublicKeys_set_Signer(p uint64, v uint64) {
189189
return
190190
}
191191
obj.(*gssh.PublicKeys).Signer = *signer.(*ssh.Signer)
192-
}
192+
}

cshared/blame_cshared.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ func c_Blame_get_Rev(b uint64) *C.char {
2727
return CBytes(blame.Rev[:])
2828
}
2929

30-
3130
//export c_Blame_get_Lines_len
3231
func c_Blame_get_Lines_len(b uint64) int {
3332
obj, ok := GetObject(Handle(b))
@@ -48,4 +47,3 @@ func c_Blame_get_Lines_item(b uint64, i int) {
4847
line := blame.Lines[i]
4948
_ = line
5049
}
51-

cshared/file_cshared.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ func c_File_Read(b uint64) (int, *C.char) {
7272
if err != nil {
7373
return ErrorCodeInternal, C.CString(err.Error())
7474
}
75-
data, err := ioutil.ReadAll(reader)
75+
data, err := ioutil.ReadAll(reader)
7676
reader.Close()
7777
if err != nil {
7878
return ErrorCodeInternal, C.CString(err.Error())

cshared/objects.go

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,22 @@ import (
55
"C"
66
"fmt"
77
"math"
8-
"sync"
98
"reflect"
9+
"sync"
1010
)
1111

1212
type Handle uint64
1313

1414
const (
15-
ErrorCodeSuccess = iota
15+
ErrorCodeSuccess = iota
1616
ErrorCodeNotFound = -iota
1717
ErrorCodeInternal = -iota
1818
)
1919

2020
const MessageNotFound string = "object not found"
2121
const InvalidHandle Handle = 0
2222
const IH uint64 = uint64(InvalidHandle)
23+
2324
var counter Handle = InvalidHandle
2425
var opMutex sync.Mutex
2526
var registryHandle2Obj map[Handle]interface{} = map[Handle]interface{}{}
@@ -43,7 +44,7 @@ func RegisterObject(obj interface{}) Handle {
4344
defer opMutex.Unlock()
4445
handles, ok := registryObj2Handle[data_ptr]
4546
if ok {
46-
for _, h := range(handles) {
47+
for _, h := range handles {
4748
other, ok := registryHandle2Obj[h]
4849
if !ok {
4950
panic("Inconsistent internal object mapping state (1)")
@@ -56,7 +57,7 @@ func RegisterObject(obj interface{}) Handle {
5657
}
5758
}
5859
}
59-
handle := getNewHandle()
60+
handle := getNewHandle()
6061
registryHandle2Obj[handle] = obj
6162
registryObj2Handle[data_ptr] = append(registryObj2Handle[data_ptr], handle)
6263
if trace {
@@ -67,7 +68,7 @@ func RegisterObject(obj interface{}) Handle {
6768

6869
func UnregisterObject(handle Handle) int {
6970
if trace {
70-
fmt.Printf("UnregisterObject %d\n", handle)
71+
fmt.Printf("UnregisterObject %d\n", handle)
7172
}
7273
if handle == InvalidHandle {
7374
return ErrorCodeNotFound
@@ -83,23 +84,23 @@ func UnregisterObject(handle Handle) int {
8384
other_handles, ok := registryObj2Handle[data_ptr]
8485
if !ok {
8586
panic(fmt.Sprintf("Inconsistent internal object mapping state (2): %d",
86-
handle))
87+
handle))
8788
}
8889
hi := -1
89-
for i, h := range(other_handles) {
90+
for i, h := range other_handles {
9091
if h == handle {
9192
hi = i
9293
break
9394
}
9495
}
9596
if hi < 0 {
9697
panic(fmt.Sprintf("Inconsistent internal object mapping state (3): %d",
97-
handle))
98+
handle))
9899
}
99100
if len(other_handles) == 1 {
100101
delete(registryObj2Handle, data_ptr)
101102
} else {
102-
registryObj2Handle[data_ptr] = append(other_handles[:hi], other_handles[hi + 1:]...)
103+
registryObj2Handle[data_ptr] = append(other_handles[:hi], other_handles[hi+1:]...)
103104
}
104105
if trace {
105106
c_dump_objects()
@@ -125,7 +126,7 @@ func GetHandle(obj interface{}) (Handle, bool) {
125126
if !ok {
126127
return InvalidHandle, false
127128
}
128-
for _, h := range(handles) {
129+
for _, h := range handles {
129130
candidate := registryHandle2Obj[h]
130131
if candidate == obj {
131132
return h, true
@@ -143,13 +144,13 @@ func CopyString(str string) string {
143144
// https://github.com/golang/go/issues/14838
144145
func CBytes(bytes []byte) *C.char {
145146
ptr := C.malloc(C.size_t(len(bytes)))
146-
copy((*[1<<30]byte)(ptr)[:], bytes)
147+
copy((*[1 << 30]byte)(ptr)[:], bytes)
147148
return (*C.char)(ptr)
148149
}
149150

150151
func SafeIsNil(v reflect.Value) bool {
151-
defer func() { recover() }()
152-
return v.IsNil()
152+
defer func() { recover() }()
153+
return v.IsNil()
153154
}
154155

155156
//export c_dispose
@@ -165,17 +166,17 @@ func c_objects_size() int {
165166
//export c_dump_objects
166167
func c_dump_objects() {
167168
fmt.Printf("handles (%d):\n", len(registryHandle2Obj))
168-
for h, obj := range(registryHandle2Obj) {
169+
for h, obj := range registryHandle2Obj {
169170
fmt.Printf("0x%x\t0x%x %v\n", h,
170171
reflect.ValueOf(&obj).Elem().InterfaceData()[1], obj)
171172
}
172173
fmt.Println()
173174
phs := 0
174-
for _, h := range(registryObj2Handle) {
175+
for _, h := range registryObj2Handle {
175176
phs += len(h)
176177
}
177178
fmt.Printf("pointers (%d):\n", phs)
178-
for ptr, h := range(registryObj2Handle) {
179+
for ptr, h := range registryObj2Handle {
179180
fmt.Printf("0x%x\t%v\n", ptr, h)
180181
}
181182
}

cshared/objects_cshared.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ func c_Blob_Read(b uint64) (int, *C.char) {
9090
if err != nil {
9191
return ErrorCodeInternal, C.CString(err.Error())
9292
}
93-
data, err := ioutil.ReadAll(reader)
93+
data, err := ioutil.ReadAll(reader)
9494
reader.Close()
9595
if err != nil {
9696
return ErrorCodeInternal, C.CString(err.Error())
@@ -106,4 +106,4 @@ func c_Blob_Type(c uint64) int8 {
106106
}
107107
blob := obj.(*git.Blob)
108108
return int8(blob.Type())
109-
}
109+
}

cshared/std_cshared.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func c_std_map_get_str_str(m uint64, key string) *C.char {
2525
return nil
2626
}
2727
if (val.Kind() == reflect.Slice || val.Kind() == reflect.Array) &&
28-
val.Type().Elem().Kind() == reflect.Uint8 {
28+
val.Type().Elem().Kind() == reflect.Uint8 {
2929
arr := make([]byte, val.Len(), val.Len())
3030
reflect.Copy(reflect.ValueOf(arr), val)
3131
return CBytes(arr)

cshared/tag_cshared.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ package main
44
import (
55
"C"
66
"io"
7-
7+
88
"gopkg.in/src-d/go-git.v4"
99
"gopkg.in/src-d/go-git.v4/core"
1010
)
@@ -37,7 +37,7 @@ func c_Tag_get_Tagger(t uint64) uint64 {
3737
}
3838

3939
func c_Tag_get_Message(t uint64) *C.char {
40-
obj, ok := GetObject(Handle(t))
40+
obj, ok := GetObject(Handle(t))
4141
if !ok {
4242
return nil
4343
}
@@ -46,7 +46,7 @@ func c_Tag_get_Message(t uint64) *C.char {
4646
}
4747

4848
func c_Tag_get_TargetType(t uint64) int8 {
49-
obj, ok := GetObject(Handle(t))
49+
obj, ok := GetObject(Handle(t))
5050
if !ok {
5151
return -1
5252
}
@@ -55,7 +55,7 @@ func c_Tag_get_TargetType(t uint64) int8 {
5555
}
5656

5757
func c_Tag_get_Target(t uint64) *C.char {
58-
obj, ok := GetObject(Handle(t))
58+
obj, ok := GetObject(Handle(t))
5959
if !ok {
6060
return nil
6161
}

0 commit comments

Comments
 (0)