Skip to content
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

Add Mime() to exclude parameters in generated string #5

Merged
merged 2 commits into from May 9, 2022

Conversation

gwvandesteeg
Copy link

Add a Mime() method on the ContentType to be able to get the MIME only
part without the parameters for simpler comparison against other
MIME-types in for example switch statements.

Partially closes #3

Add a Mime() method on the ContentType to be able to get the MIME only
part without the parameters for simpler comparison against other
MIME-types in for example switch statements.
Copy link

@GitOpsBot GitOpsBot left a comment

Choose a reason for hiding this comment

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

GoGitOps Review

Grade: A+ (94.1%)

Files: 2

Issues: 1

gofmt: 100%

go_vet: 100%

golint: 100%

gocyclo: 50%

contenttype.go
	Line 379: warning: cyclomatic complexity 24 of function GetAcceptableMediaTypeFromHeader() is high (> 15) (gocyclo)
contenttype.go
	Line 52: warning: cyclomatic complexity 17 of function isTokenChar() is high (> 15) (gocyclo)

license: 100%

ineffassign: 100%

misspell: 100%

This report was generated using GoGitOps.

contenttype.go Outdated
@@ -300,6 +300,19 @@ func (mediaType *MediaType) String() string {
return stringBuilder.String()
}

// Mime returns the MIME type without any of the parameters
func (mediaType MediaType) Mime() string {
Copy link
Owner

Choose a reason for hiding this comment

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

Golang naming convention states that acronyms must be capitalized (for example https://pkg.go.dev/net/http#ParseHTTPVersion) so this should be named MIME.

Copy link
Author

Choose a reason for hiding this comment

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

True, i'll change that.

Copy link
Owner

Choose a reason for hiding this comment

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

Thanks!

Go conventions speify abbreviations are to be kept uppercase.
@elnormous elnormous merged commit dcd30b1 into elnormous:master May 9, 2022
@elnormous
Copy link
Owner

Thank you!

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.

Add compare/equal method to media type
3 participants