Skip to content
This repository has been archived by the owner on Jul 12, 2022. It is now read-only.

add Unset example #49

Closed
wants to merge 2 commits into from
Closed

Conversation

andri-de
Copy link

@andri-de andri-de commented Oct 30, 2017

Closes #47

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling fb641dd on andri-de:add-unset-example into 97bd93e on rlespinasse:master.

@rlespinasse rlespinasse mentioned this pull request Oct 30, 2017
data1 := []byte{0x00, 0x00}
data2 := []byte{0x00}
val, err := Unset(data1, data2)
if err == nil || val != nil {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just test the error here, the test of the val was only be done in the associated testcase.

data2 := []byte{0x00}
val, err := Unset(data1, data2)
if err == nil || val != nil {
log.Println("Unset with two byte slices of different size needs to return an error and no value")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't log the same text as the testcase. It's a example, not a test.
You need to show a possible usage in a example.

log.Println("Unset with two byte slices of different size needs to return an error and no value")
}
fmt.Printf("%x\n", val)
// Output:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For this function, you have 2 possible outputs, val is empty or err is empty.

You need to create 2 examples, ExampleUnset() and ExampleUnset_error (see https://blog.golang.org/examples - Example function names section)

import "fmt"
import (
"fmt"
"log"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't use log, keep it to fmt

@rlespinasse rlespinasse changed the title add unset examle add Unset example Oct 30, 2017
@rlespinasse rlespinasse self-assigned this Oct 30, 2017
@rlespinasse
Copy link
Owner

For the ExampleUnset, use the output bada55 and create the data, and unsetData to provide this output.

This was referenced Oct 31, 2017
@rlespinasse
Copy link
Owner

@andri-de Since #hacktoberfest 2017 is close, will you try to finalize this pull-request?

@andri-de andri-de closed this Nov 7, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants