Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

go: update code to more modern version #887

Merged
merged 1 commit into from
Aug 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions bindings/go/http/batch/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ dapr run --app-id batch-http --app-port 6003 --dapr-http-port 3503 --dapr-grpc-p
import (
"encoding/json"
"fmt"
"io/ioutil"
"io"
"log"
"net/http"
"os"
Expand Down Expand Up @@ -56,7 +56,7 @@ func processBatch(w http.ResponseWriter, r *http.Request) {

defer fileContent.Close()

byteResult, _ := ioutil.ReadAll(fileContent)
byteResult, _ := io.ReadAll(fileContent)

var orders Orders

Expand Down
4 changes: 2 additions & 2 deletions bindings/go/sdk/batch/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"context"
"encoding/json"
"fmt"
"io/ioutil"
"io"
"log"
"net/http"
"os"
Expand Down Expand Up @@ -57,7 +57,7 @@ func processBatch(w http.ResponseWriter, r *http.Request) {

defer fileContent.Close()

byteResult, _ := ioutil.ReadAll(fileContent)
byteResult, _ := io.ReadAll(fileContent)

var orders Orders

Expand Down
10 changes: 5 additions & 5 deletions configuration/go/http/order-processor/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"encoding/json"
"fmt"
"io/ioutil"
"io"
"log"
"net/http"
"os"
Expand Down Expand Up @@ -39,7 +39,7 @@ func main() {
fmt.Print("Could not get config item, err:" + err.Error())
os.Exit(1)
}
result, _ := ioutil.ReadAll(getResponse.Body)
result, _ := io.ReadAll(getResponse.Body)
fmt.Println("Configuration for "+item+":", string(result))
}

Expand Down Expand Up @@ -69,7 +69,7 @@ func subscribeToConfigUpdates(subscriptionId *string) {
fmt.Println("Error subscribing to config updates, err:" + err.Error())
os.Exit(1)
}
sub, err := ioutil.ReadAll(subscription.Body)
sub, err := io.ReadAll(subscription.Body)
if err != nil {
fmt.Print("Unable to read subscription id, err: " + err.Error())
os.Exit(1)
Expand Down Expand Up @@ -115,7 +115,7 @@ func unsubscribeFromConfigUpdates(subscriptionId string) {
if err != nil {
fmt.Println("Error unsubscribing from config updates, err:" + err.Error())
}
unsub, err := ioutil.ReadAll(unsubscribe.Body)
unsub, err := io.ReadAll(unsubscribe.Body)
if err != nil {
fmt.Print("Unable to read unsubscribe response, err: " + err.Error())
}
Expand All @@ -128,7 +128,7 @@ func unsubscribeFromConfigUpdates(subscriptionId string) {
}

func configUpdateHandler(w http.ResponseWriter, r *http.Request) {
body, err := ioutil.ReadAll(r.Body)
body, err := io.ReadAll(r.Body)
if err != nil {
log.Panic(err)
}
Expand Down
7 changes: 4 additions & 3 deletions pub_sub/go/http/order-processor/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ package main

import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"io"
"log"
"net/http"
"os"
Expand Down Expand Up @@ -40,7 +41,7 @@ func getOrder(w http.ResponseWriter, r *http.Request) {
}

func postOrder(w http.ResponseWriter, r *http.Request) {
data, err := ioutil.ReadAll(r.Body)
data, err := io.ReadAll(r.Body)
if err != nil {
log.Fatal(err)
}
Expand Down Expand Up @@ -79,7 +80,7 @@ func main() {

// Start the server; this is a blocking call
err := http.ListenAndServe(":"+appPort, r)
if err != http.ErrServerClosed {
if !errors.Is(err, http.ErrServerClosed) {
log.Panic(err)
}
}
4 changes: 2 additions & 2 deletions secrets_management/go/http/order-processor/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package main

import (
"fmt"
"io/ioutil"
"io"
"net/http"
"os"
)
Expand All @@ -25,6 +25,6 @@ func main() {
fmt.Print(err.Error())
os.Exit(1)
}
result, _ := ioutil.ReadAll(getResponse.Body)
result, _ := io.ReadAll(getResponse.Body)
fmt.Println("Fetched Secret: ", string(result))
}
4 changes: 2 additions & 2 deletions service_invocation/go/http/checkout/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package main

import (
"fmt"
"io/ioutil"
"io"
"log"
"net/http"
"os"
Expand Down Expand Up @@ -40,7 +40,7 @@ func main() {
}

// Read the response
result, err := ioutil.ReadAll(response.Body)
result, err := io.ReadAll(response.Body)
if err != nil {
log.Fatal(err)
}
Expand Down
7 changes: 4 additions & 3 deletions service_invocation/go/http/order-processor/app.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
package main

import (
"errors"
"fmt"
"io/ioutil"
"io"
"log"
"net/http"

"github.com/gorilla/mux"
)

func getOrder(w http.ResponseWriter, r *http.Request) {
data, err := ioutil.ReadAll(r.Body)
data, err := io.ReadAll(r.Body)
if err != nil {
log.Println("Error reading body:", err.Error())
}
Expand All @@ -29,7 +30,7 @@ func main() {
// Start the server listening on port 6001
// This is a blocking call
err := http.ListenAndServe(":6006", r)
if err != http.ErrServerClosed {
if !errors.Is(err, http.ErrServerClosed) {
log.Println("Error starting HTTP server")
}
}
4 changes: 2 additions & 2 deletions state_management/go/http/order-processor/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"io"
"log"
"net/http"
"os"
Expand Down Expand Up @@ -51,7 +51,7 @@ func main() {
if err != nil {
panic(err)
}
result, err := ioutil.ReadAll(getResponse.Body)
result, err := io.ReadAll(getResponse.Body)
if err != nil {
panic(err)
}
Expand Down