Conditions | 2 |
Total Lines | 72 |
Code Lines | 51 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | package internal |
||
149 | func getTestData() map[string]struct { |
||
150 | inputValue interface{} |
||
151 | output bool |
||
152 | } { |
||
153 | testData := map[string]struct { |
||
154 | inputValue interface{} |
||
155 | output bool |
||
156 | }{ |
||
157 | "is_array": { |
||
158 | inputValue: [4]int64{-100, -5, 30, 100}, |
||
159 | output: true, |
||
160 | }, |
||
161 | "is_slice": { |
||
162 | inputValue: []int64{-100, -5, 30, 100}, |
||
163 | output: true, |
||
164 | }, |
||
165 | "is_string": { |
||
166 | inputValue: "hello gotilty", |
||
167 | output: true, |
||
168 | }, |
||
169 | "is_bool": { |
||
170 | inputValue: false, |
||
171 | output: true, |
||
172 | }, |
||
173 | "is_integer": { |
||
174 | inputValue: int16(2), |
||
175 | output: true, |
||
176 | }, |
||
177 | "is_float": { |
||
178 | inputValue: float64(1523.2323), |
||
179 | output: true, |
||
180 | }, |
||
181 | "is_number": { |
||
182 | inputValue: float64(1523.2323), |
||
183 | output: true, |
||
184 | }, |
||
185 | "is_func": { |
||
186 | inputValue: func() { |
||
187 | fmt.Println("hello gotilty") |
||
188 | }, |
||
189 | output: true, |
||
190 | }, |
||
191 | "is_struct": { |
||
192 | inputValue: user{ |
||
193 | name: "Martha", |
||
194 | age: 15, |
||
195 | }, |
||
196 | output: true, |
||
197 | }, |
||
198 | "is_pointer": { |
||
199 | inputValue: &user{ |
||
200 | name: "Martha", |
||
201 | age: 15, |
||
202 | }, |
||
203 | output: true, |
||
204 | }, |
||
205 | "is_chan": { |
||
206 | inputValue: make(chan int), |
||
207 | output: true, |
||
208 | }, |
||
209 | "is_map": { |
||
210 | inputValue: map[string]struct { |
||
211 | test bool |
||
212 | }{ |
||
213 | "test": { |
||
214 | test: true, |
||
215 | }, |
||
216 | }, |
||
217 | output: true, |
||
218 | }, |
||
219 | } |
||
220 | return testData |
||
221 | } |
||
222 |