Skip to content

support chain-calls#59

Closed
sdbaiguanghe wants to merge 2 commits intogorilla:masterfrom
sdbaiguanghe:master
Closed

support chain-calls#59
sdbaiguanghe wants to merge 2 commits intogorilla:masterfrom
sdbaiguanghe:master

Conversation

@sdbaiguanghe
Copy link

could support chain-calls? I think it is more convenient。

Before

  decoder := schema.NewDecoder()
  decoder.SetAliasTag("query")
  decoder.ZeroEmpty(true)
  decoder.IgnoreUnknownKeys(true)
 // err := decoder.Decode(dst,src)

After

   decoder := schema.NewDecoder().SetAliasTag("query").ZeroEmpty(true).IgnoreUnknownKeys(true)
  // err := decoder.Decode(dst,src)

@sdbaiguanghe
Copy link
Author

sdbaiguanghe commented Apr 26, 2016

@elithrar why check failed? what's meaning of the error information (The command "go get golang.org/x/tools/cmd/vet" failed and exited with 1 during),what should i do next?

@elithrar
Copy link
Contributor

This is a build error with changes to go vet, not with your code.

I'll take a look at your PR tonight.

On Tue, Apr 26, 2016 at 2:13 AM sdbaiguanghe notifications@github.com
wrote:

@elithrar https://github.com/elithrar why check failed? what's mean of
the error information ---(The command "go get golang.org/x/tools/cmd/vet"
failed and exited with 1 during)
https://travis-ci.org/gorilla/schema/builds/125733232,what should i do
next?


You are receiving this because you were mentioned.

Reply to this email directly or view it on GitHub
#59 (comment)

@elithrar elithrar self-assigned this Apr 26, 2016
@elithrar
Copy link
Contributor

Can you write a test for this that demonstrates the usage? Helps prevent regression. Otherwise looks good.

@sdbaiguanghe
Copy link
Author

I modified decoder_test.go for demonstrates and test the new usage . Is that what needed?

@kisielk
Copy link
Contributor

kisielk commented Jul 12, 2016

Technically this breaks the API guarantee if someone has created an interface that Decoder conforms to.

@kisielk
Copy link
Contributor

kisielk commented Jul 12, 2016

I think it's a pretty unlikely case though, I can't really see a reason to do that apart from in unit tests, and even then...

@kisielk
Copy link
Contributor

kisielk commented Jun 12, 2017

I'm going to close this. There's really not that much benefit since there's only a few options, and it breaks the public API.

@kisielk kisielk closed this Jun 12, 2017
lithammer added a commit to lithammer/schema that referenced this pull request Jun 30, 2022
Since gorillaGH-59 was rejected on the basis that it wasn't useful enough to
break the public API. I took a stab at an alternate solution that
doesn't break the public API. While still allowing one to configure the
decoder when defining it as a package global (as recommended by the
README).

```go
var decoder = NewDecoder(func(d *Decoder) {
	d.IgnoreUnknownKeys(true)
})
```
lithammer added a commit to lithammer/schema that referenced this pull request Sep 26, 2024
Since gorillaGH-59 was rejected on the basis that it wasn't useful enough to
break the public API. I took a stab at an alternate solution that
doesn't break the public API. While still allowing one to configure the
encoder and decoder when defining it as a package global (as recommended
by the README).

```go
var decoder = NewDecoder(WithIgnoreUnknownKeysDecoderOpt(true))
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants