- commit
- 1e355f87c8906ed23c22a833155f51de9fbf5e6d
- parent
- 09793099b4cc716a93929e04e6ca3c6ebadad6a5
- Author
- Tobias Bengfort <tobias.bengfort@posteo.de>
- Date
- 2025-06-08 05:51
update deprecated ioutil functions
Diffstat
| M | via.go | 13 | +++++++------ |
1 files changed, 7 insertions, 6 deletions
diff --git a/via.go b/via.go
@@ -4,9 +4,10 @@ import ( 4 4 "context" 5 5 "encoding/base64" 6 6 "encoding/json" -1 7 "errors" 7 8 "flag" 8 9 "fmt"9 -1 "io/ioutil"-1 10 "io" 10 11 "log" 11 12 "net" 12 13 "net/http" @@ -56,7 +57,7 @@ func (topic *Topic) storeHistory(key string) { 56 57 } 57 58 58 59 path := getStorePath(key)59 -1 err = ioutil.WriteFile(path, content, 0644)-1 60 err = os.WriteFile(path, content, 0644) 60 61 if err != nil { 61 62 log.Println("error storing history:", err) 62 63 return @@ -66,9 +67,9 @@ func (topic *Topic) storeHistory(key string) { 66 67 func (topic *Topic) restoreHistory(key string) { 67 68 path := getStorePath(key) 68 6969 -1 content, err := ioutil.ReadFile(path)-1 70 content, err := os.ReadFile(path) 70 71 if err != nil {71 -1 if !os.IsNotExist(err) {-1 72 if !errors.Is(err, os.ErrNotExist) { 72 73 log.Println("error restoring history:", err) 73 74 } 74 75 return @@ -191,7 +192,7 @@ func popChannel(key string, ch chan Msg) { 191 192 } 192 193 193 194 func post(w http.ResponseWriter, r *http.Request) {194 -1 body, err := ioutil.ReadAll(r.Body)-1 195 body, err := io.ReadAll(r.Body) 195 196 if err != nil { 196 197 log.Println("error reading request body:", err) 197 198 http.Error(w, "Internal Server Error", http.StatusInternalServerError) @@ -278,7 +279,7 @@ func put(w http.ResponseWriter, r *http.Request) { 278 279 return 279 280 } 280 281281 -1 body, err := ioutil.ReadAll(r.Body)-1 282 body, err := io.ReadAll(r.Body) 282 283 if err != nil { 283 284 log.Println("error reading request body:", err) 284 285 http.Error(w, "Internal Server Error", http.StatusInternalServerError)