@@ -22,43 +22,11 @@ import (
22
22
"github.com/zeebo/blake3"
23
23
)
24
24
25
- func removeDuplicates [T comparable ](elements []T ) []T {
26
- seen := make (map [T ]struct {})
27
- result := []T {}
28
- for _ , element := range elements {
29
- if _ , ok := seen [element ]; ! ok {
30
- seen [element ] = struct {}{}
31
- result = append (result , element )
32
- }
33
- }
34
- return result
35
- }
36
-
37
- func contains (slice []string , str string ) bool {
38
- for _ , v := range slice {
39
- if v == str {
40
- return true
41
- }
42
- }
43
- return false
44
- }
45
-
46
25
func fileExists (filePath string ) bool {
47
26
_ , err := os .Stat (filePath )
48
27
return ! os .IsNotExist (err )
49
28
}
50
29
51
- func isDirectory (path string ) (bool , error ) {
52
- info , err := os .Stat (path )
53
- if err != nil {
54
- if os .IsNotExist (err ) {
55
- return false , nil
56
- }
57
- return false , err
58
- }
59
- return info .IsDir (), nil
60
- }
61
-
62
30
func isExecutable (filePath string ) bool {
63
31
info , err := os .Stat (filePath )
64
32
if err != nil {
@@ -178,22 +146,6 @@ func bEntryOfinstalledBinary(binaryPath string) binaryEntry {
178
146
return trackedBEntry
179
147
}
180
148
181
- func errorEncoder (format string , args ... interface {}) int {
182
- formattedErrorMessage := fmt .Sprintf (format , args ... )
183
-
184
- var sum int
185
- for _ , char := range formattedErrorMessage {
186
- sum += int (char )
187
- }
188
- errorCode := sum % 256
189
- fmt .Fprint (os .Stderr , formattedErrorMessage )
190
- return errorCode
191
- }
192
-
193
- func errorOut (format string , args ... interface {}) {
194
- os .Exit (errorEncoder (format , args ... ))
195
- }
196
-
197
149
func getTerminalWidth () int {
198
150
w , _ , _ := term .GetSize (int (os .Stdout .Fd ()))
199
151
if w != 0 {
@@ -286,7 +238,7 @@ func embedBEntry(binaryPath string, bEntry binaryEntry) error {
286
238
287
239
func readEmbeddedBEntry (binaryPath string ) (binaryEntry , error ) {
288
240
if ! fileExists (binaryPath ) {
289
- return binaryEntry {}, fmt .Errorf ("Error : Tried to get EmbeddedBEntry of non-existant file: %s" , binaryPath )
241
+ return binaryEntry {}, fmt .Errorf ("error : Tried to get EmbeddedBEntry of non-existant file: %s" , binaryPath )
290
242
}
291
243
292
244
fullName , err := xattr .Get (binaryPath , "user.FullName" )
@@ -330,7 +282,7 @@ func removeNixGarbageFoundInTheRepos(filePath string) error {
330
282
331
283
func decodeRepoIndex (url string ) ([]binaryEntry , error ) {
332
284
if url == "" {
333
- return nil , fmt .Errorf ("repository index URL is empty. Please check your configuration or remove it. " )
285
+ return nil , fmt .Errorf ("repository index URL is empty. Please check your configuration or remove it" )
334
286
}
335
287
336
288
req , err := http .NewRequest ("GET" , url , nil )
@@ -344,7 +296,7 @@ func decodeRepoIndex(url string) ([]binaryEntry, error) {
344
296
client := & http.Client {}
345
297
response , err := client .Do (req )
346
298
if err != nil {
347
- return nil , fmt .Errorf ("error fetching from %s: %v. Please check your configuration's repo_urls. Ensure your network has access to the internet. " , url , err )
299
+ return nil , fmt .Errorf ("error fetching from %s: %v. Please check your configuration's repo_urls. Ensure your network has access to the internet" , url , err )
348
300
}
349
301
defer response .Body .Close ()
350
302
bodyReader := response .Body
0 commit comments