Skip to content

Commit 3744079

Browse files
authored
CLOUDP-213199 Atlas Go SDK docs changes for binary responses (#245)
1 parent 60a45f7 commit 3744079

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

docs/doc_5_best_practices.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,15 @@ When you have confirmed that the `time.Time pointer` is non-nil, you can safely
5656

5757
## Working with Binary Responses
5858

59-
In the Atlas Go SDK, the `io.ReadCloser` type is used to return binary data from APIs.
59+
In the Atlas Go SDK, the `io.ReadCloser` type is used to return binary data using the APIs.
6060

61-
1. Use `io.Copy` if the intention is to store on a file or pass through another steam
61+
- Use `io.Copy` to store on a file or pass through another steam.
6262

63-
2. Use `io.ReadAll` if the intention is to read all bytes in memory
63+
- Use `io.ReadAll` to read all bytes in memory.
6464

65-
3. Call the `.Close()` function after done reading the data
65+
- Call the `.Close()` function after reading the data
66+
67+
Note: see example in [examples/download/downloadLogs.go](../examples/download/downloadLogs.go)
6668

6769
## Use Method for Creating Models
6870

examples/download/downloadLogs.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ func main() {
4040
if projects.GetTotalCount() == 0 {
4141
log.Fatal("account should have at least single project")
4242
}
43-
var out io.Writer = os.Stdout
4443
projectId := projects.GetResults()[0].GetId()
4544

4645
// -- 2. Get first Process
@@ -61,6 +60,6 @@ func main() {
6160
defer func() {
6261
_ = logs.Close()
6362
}()
64-
_, err = io.Copy(out, logs)
63+
_, err = io.Copy(os.Stdout, logs)
6564
examples.HandleErr(err, nil)
6665
}

0 commit comments

Comments
 (0)