Changeset 8 in code


Ignore:
Timestamp:
Dec 17, 2022, 4:57:12 PM (2 years ago)
Author:
koizumi.aoi
Message:

How can you be in two places at once when you're not anywhere at all?

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/main.go

    r7 r8  
    77        "flag"
    88        "fmt"
    9         "io"
    109        "log"
    1110        "net/http"
     
    4342        var queryURL = instance + "?engine=" + engine + "&from=" + from + "&to=" + to + "&text=" + encinput
    4443        // Begin the request and process the response
    45         req, err := http.Get(queryURL)
     44        resp, err := http.Get(queryURL)
    4645        sanityCheck(err)
    47         defer req.Body.Close()
    48         resp, err := io.ReadAll(req.Body)
    49         _ = json.Unmarshal([]byte(resp), &translate)
     46        defer resp.Body.Close()
     47        _ = json.NewDecoder(resp.Body).Decode(&translate)
    5048        sanityCheck(err)
    5149        // Pretty-print both the input and the output given.
Note: See TracChangeset for help on using the changeset viewer.