Skip to content

Commit

Permalink
added tweet posted message
Browse files Browse the repository at this point in the history
  • Loading branch information
devhindo committed Apr 15, 2024
1 parent 583589d commit dfe36aa
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
18 changes: 12 additions & 6 deletions src/cli/tweet/post.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,21 +46,27 @@ func postT(url string, t Tweet) {
}

resp, err := http.Post(url, "application/json", bytes.NewBuffer(jsonBytes))

if err != nil {
fmt.Println("can't reach server to post a tweet")
os.Exit(0)
}

defer resp.Body.Close()

_, err = io.ReadAll(resp.Body)
if err != nil {
//Failed to read response.
panic(err)
}
body, err := io.ReadAll(resp.Body)
if err != nil {
//Failed to read response.
panic(err)
}


var r response
err = json.Unmarshal(body, &r)
if err != nil {
fmt.Printf("Failed to unmarshal response")
//Failed to unmarshal response.
return
}


//Convert bytes to String and print
Expand Down
4 changes: 2 additions & 2 deletions src/cli/x/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ package x
import "fmt"

func Version() {
fmt.Println("x CLI v1.1.1")
}
fmt.Println("x CLI v1.1.2")
}

0 comments on commit dfe36aa

Please sign in to comment.