Skip to content

Commit

Permalink
Update feedback example to use safe delete (and proper method calls)
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric Mann committed Oct 12, 2017
1 parent d645821 commit c6dc65c
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions example/feedback.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,16 @@ func main() {
printRecords("")

// Create a new "feedback" record; this is the type the CLI uses
feedbackRecord := client.NewRecord("feedback")
feedbackRecord.Data["comment"] = "This is some example feedback!"
feedbackRecord.Data["interface"] = "Go Example Code"
recordID, err := client.Write(context.Background(), feedbackRecord)
feedbackData := make(map[string]string)
feedbackData["comment"] = "This is some example feedback!"
feedbackData["interface"] = "Go Example Code"
record, err := client.Write(context.Background(), "feedback", feedbackData, nil)
chk(err)

// Read back the feedback we just put into the database
newFeedbackRecord, err := client.Read(context.Background(), recordID)
newFeedbackRecord, err := client.Read(context.Background(), record.Meta.RecordID)
chk(err)
fmt.Println("Read record id " + recordID + ": " + newFeedbackRecord.Data["comment"])
fmt.Println("Read record id " + record.Meta.RecordID + ": " + newFeedbackRecord.Data["comment"])

// Fetch the Tozny feedback email address public key and client ID
feedbackClient, err := client.GetClientInfo(context.Background(), "db1744b9-3fb6-4458-a291-0bc677dba08b")
Expand All @@ -73,7 +73,7 @@ func main() {

// Delete the record we just created to keep things tidy.
// Comment out this line if you want to keep it
err = client.Delete(context.Background(), recordID)
err = client.Delete(context.Background(), record.Meta.RecordID, record.Meta.Version)
chk(err)

fmt.Println("Current list of records after deleting:")
Expand Down

0 comments on commit c6dc65c

Please sign in to comment.