8000 [cassette]: Use omitempty in yaml field serialization by maruel · Pull Request #110 · dnaeon/go-vcr · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[cassette]: Use omitempty in yaml field serialization #110

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 21, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions pkg/cassette/cassette.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,20 +65,20 @@ type Request struct {
ProtoMajor int `yaml:"proto_major"`
ProtoMinor int `yaml:"proto_minor"`
ContentLength int64 `yaml:"content_length"`
TransferEncoding []string `yaml:"transfer_encoding"`
Trailer http.Header `yaml:"trailer"`
TransferEncoding []string `yaml:"transfer_encoding,omitempty"`
Trailer http.Header `yaml:"trailer,omitempty"`
Host string `yaml:"host"`
RemoteAddr string `yaml:"remote_addr"`
RequestURI string `yaml:"request_uri"`
RemoteAddr string `yaml:"remote_addr,omitempty"`
RequestURI string `yaml:"request_uri,omitempty"`

// Body of request
Body string `yaml:"body"`
Body string `yaml:"body,omitempty"`

// Form values
Form url.Values `yaml:"form"`
Form url.Values `yaml:"form,omitempty"`

// Request headers
Headers http.Header `yaml:"headers"`
Headers http.Header `yaml:"headers,omitempty"`

// Request URL
URL string `yaml:"url"`
Expand All @@ -92,10 +92,10 @@ type Response struct {
Proto string `yaml:"proto"`
ProtoMajor int `yaml:"proto_major"`
ProtoMinor int `yaml:"proto_minor"`
TransferEncoding []string `yaml:"transfer_encoding"`
Trailer http.Header `yaml:"trailer"`
TransferEncoding []string `yaml:"transfer_encoding,omitempty"`
Trailer http.Header `yaml:"trailer,omitempty"`
ContentLength int64 `yaml:"content_length"`
Uncompressed bool `yaml:"uncompressed"`
Uncompressed bool `yaml:"uncompressed,omitempty"`

// Body of response
Body string `yaml:"body"`
Expand Down Expand Up @@ -482,7 +482,7 @@ func (c *Cassette) Save() error {
// Create directory for cassette if missing
cassetteDir := filepath.Dir(c.File)
if _, err := os.Stat(cassetteDir); os.IsNotExist(err) {
if err = os.MkdirAll(cassetteDir, 0755); err != nil {
if err = os.MkdirAll(cassetteDir, 0o755); err != nil {
return err
}
}
Expand Down
Loading
0