https://github.com/joaorafa19/file-storage-server
https://github.com/joaorafa19/file-storage-server
Last synced: 4 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/joaorafa19/file-storage-server
- Owner: JoaoRafa19
- Created: 2024-08-23T13:38:32.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2024-09-11T13:40:53.000Z (9 months ago)
- Last Synced: 2024-12-28T11:43:11.702Z (5 months ago)
- Language: Go
- Size: 23.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# File storage Server
## Testing
Test:
```shell
go test ./...
```Coverage:
```shell
go test -coverprofile cover.out && go tool cover -html=cover.out
```### Diferences betwen the original code
- TCP Error
Originaly the TCP Transport handle the decode error by continue looping
after a error but we can type assert the error.by `var.(type)`
```go
if err != nil {
t,isOpError := err.(*net.OpError)
if isOpError { // Net Closes
fmt.Println(t)
return
}fmt.Printf("TCP ERROR: %s\n", err) // Everything else (failure payload)
continue
}
```- Check File existance
Original
```go
_,err := os.Stat(pathKey.FullPath())
if err == fs.ErrNotExist {
return false
}
return true```
Simplified
```go
_, err := os.Stat(Patkey.FullPath())
return errors.Is(err, fs.ErrNotExist)
```