Skip to content

Commit

Permalink
Change Mime() to MIME() for conventions
Browse files Browse the repository at this point in the history
Go conventions speify abbreviations are to be kept uppercase.
  • Loading branch information
gwvandesteeg committed May 9, 2022
1 parent 9d0eb67 commit 574da8b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions contenttype.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,8 +300,8 @@ func (mediaType *MediaType) String() string {
return stringBuilder.String()
}

// Mime returns the MIME type without any of the parameters
func (mediaType MediaType) Mime() string {
// MIME returns the MIME type without any of the parameters
func (mediaType MediaType) MIME() string {
var stringBuilder strings.Builder

if len(mediaType.Type) > 0 || len(mediaType.Subtype) > 0 {
Expand Down
18 changes: 9 additions & 9 deletions contenttype_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func TestString(t *testing.T) {
}
}

func TestMediaType_Mime(t *testing.T) {
func TestMediaType_MIME(t *testing.T) {
testCases := []struct {
name string
value contenttype.MediaType
Expand All @@ -123,7 +123,7 @@ func TestMediaType_Mime(t *testing.T) {
}
for _, testCase := range testCases {
t.Run(testCase.name, func(t *testing.T) {
result := testCase.value.Mime()
result := testCase.value.MIME()

if result != testCase.result {
t.Errorf("Invalid result type, got %s, exptected %s", result, testCase.result)
Expand All @@ -132,14 +132,14 @@ func TestMediaType_Mime(t *testing.T) {
}
}

// ExampleMediaType_Mime comparing to MIME types
func ExampleMediaType_Mime() {
// ExampleMediaType_MIME comparing to MIME types
func ExampleMediaType_MIME() {
mt := contenttype.NewMediaType("application/json; charset=utf-8")
fmt.Printf("Mime(): %s\n", mt.Mime())
fmt.Printf("matches: application/json: %v\n", mt.Mime() == "application/json")
fmt.Printf("matches: application/*: %v\n", mt.Mime() == "application/*")
fmt.Printf("matches: text/plain: %v\n", mt.Mime() == "text/plain")
// Output: Mime(): application/json
fmt.Printf("MIME(): %s\n", mt.MIME())
fmt.Printf("matches: application/json: %v\n", mt.MIME() == "application/json")
fmt.Printf("matches: application/*: %v\n", mt.MIME() == "application/*")
fmt.Printf("matches: text/plain: %v\n", mt.MIME() == "text/plain")
// Output: MIME(): application/json
// matches: application/json: true
// matches: application/*: false
// matches: text/plain: false
Expand Down

0 comments on commit 574da8b

Please sign in to comment.