From bae247a045db15c89d274a8fdb3fe51cec3f9fca Mon Sep 17 00:00:00 2001 From: Albert Nigmatzianov Date: Tue, 18 Jul 2017 09:54:15 +0200 Subject: [PATCH] Rename encodings --- README.md | 2 +- bench_test.go | 12 ++++++------ example_test.go | 16 ++++++++-------- id3v2.go | 10 +++++----- tag.go | 10 +++++----- tag_test.go | 16 ++++++++-------- util/encoding.go | 2 +- 7 files changed, 34 insertions(+), 34 deletions(-) diff --git a/README.md b/README.md index fdf1c73..02a2625 100644 --- a/README.md +++ b/README.md @@ -69,7 +69,7 @@ func main() { // Set comment frame. comment := id3v2.CommentFrame{ - Encoding: id3v2.ENUTF8, + Encoding: id3v2.EncodingUTF8, Language: "eng", Description: "My opinion", Text: "Very good song", diff --git a/bench_test.go b/bench_test.go index a0d7b84..089d779 100644 --- a/bench_test.go +++ b/bench_test.go @@ -72,7 +72,7 @@ func BenchmarkParseAndWrite(b *testing.B) { // Set front cover. pic := PictureFrame{ - Encoding: ENUTF8, + Encoding: EncodingUTF8, MimeType: "image/jpeg", PictureType: PTFrontCover, Description: "Front cover", @@ -82,7 +82,7 @@ func BenchmarkParseAndWrite(b *testing.B) { // Set USLT. uslt := UnsynchronisedLyricsFrame{ - Encoding: ENUTF8, + Encoding: EncodingUTF8, Language: "eng", ContentDescriptor: "Content descriptor", Lyrics: "bogem/id3v2", @@ -91,7 +91,7 @@ func BenchmarkParseAndWrite(b *testing.B) { // Set comment. comm := CommentFrame{ - Encoding: ENUTF8, + Encoding: EncodingUTF8, Language: "eng", Description: "Short description", Text: "The actual text", @@ -128,7 +128,7 @@ func BenchmarkReuseTag(b *testing.B) { // Set front cover. pic := PictureFrame{ - Encoding: ENUTF8, + Encoding: EncodingUTF8, MimeType: "image/jpeg", PictureType: PTFrontCover, Description: "Front cover", @@ -138,7 +138,7 @@ func BenchmarkReuseTag(b *testing.B) { // Set USLT. uslt := UnsynchronisedLyricsFrame{ - Encoding: ENUTF8, + Encoding: EncodingUTF8, Language: "eng", ContentDescriptor: "Content descriptor", Lyrics: "bogem/id3v2", @@ -147,7 +147,7 @@ func BenchmarkReuseTag(b *testing.B) { // Set comment. comm := CommentFrame{ - Encoding: ENUTF8, + Encoding: EncodingUTF8, Language: "eng", Description: "Short description", Text: "The actual text", diff --git a/example_test.go b/example_test.go index 8c74971..591943e 100644 --- a/example_test.go +++ b/example_test.go @@ -28,7 +28,7 @@ func Example() { // Set comment frame. comment := id3v2.CommentFrame{ - Encoding: id3v2.ENUTF8, + Encoding: id3v2.EncodingUTF8, Language: "eng", Description: "My opinion", Text: "Very good song", @@ -81,7 +81,7 @@ func ExampleTag_AddAttachedPicture() { } pic := id3v2.PictureFrame{ - Encoding: id3v2.ENUTF8, + Encoding: id3v2.EncodingUTF8, MimeType: "image/jpeg", PictureType: id3v2.PTFrontCover, Description: "Front cover", @@ -97,7 +97,7 @@ func ExampleTag_AddCommentFrame() { } comment := id3v2.CommentFrame{ - Encoding: id3v2.ENUTF8, + Encoding: id3v2.EncodingUTF8, Language: "eng", Description: "My opinion", Text: "Very good song", @@ -112,7 +112,7 @@ func ExampleTag_AddUnsynchronisedLyricsFrame() { } uslt := id3v2.UnsynchronisedLyricsFrame{ - Encoding: id3v2.ENUTF8, + Encoding: id3v2.EncodingUTF8, Language: "ger", ContentDescriptor: "Deutsche Nationalhymne", Lyrics: "Einigkeit und Recht und Freiheit...", @@ -176,7 +176,7 @@ func ExampleCommentFrame_get() { func ExampleCommentFrame_add() { tag := id3v2.NewEmptyTag() comment := id3v2.CommentFrame{ - Encoding: id3v2.ENUTF8, + Encoding: id3v2.EncodingUTF8, Language: "eng", Description: "My opinion", Text: "Very good song", @@ -211,7 +211,7 @@ func ExamplePictureFrame_add() { } pic := id3v2.PictureFrame{ - Encoding: id3v2.ENUTF8, + Encoding: id3v2.EncodingUTF8, MimeType: "image/jpeg", PictureType: id3v2.PTFrontCover, Description: "Front cover", @@ -233,7 +233,7 @@ func ExampleTextFrame_get() { func ExampleTextFrame_add() { tag := id3v2.NewEmptyTag() textFrame := id3v2.TextFrame{ - Encoding: id3v2.ENUTF8, + Encoding: id3v2.EncodingUTF8, Text: "Happy", } tag.AddFrame(tag.CommonID("Mood"), textFrame) @@ -261,7 +261,7 @@ func ExampleUnsynchronisedLyricsFrame_get() { func ExampleUnsynchronisedLyricsFrame_add() { tag := id3v2.NewEmptyTag() uslt := id3v2.UnsynchronisedLyricsFrame{ - Encoding: id3v2.ENUTF8, + Encoding: id3v2.EncodingUTF8, Language: "ger", ContentDescriptor: "Deutsche Nationalhymne", Lyrics: "Einigkeit und Recht und Freiheit...", diff --git a/id3v2.go b/id3v2.go index d5166ef..aebfd51 100644 --- a/id3v2.go +++ b/id3v2.go @@ -40,30 +40,30 @@ const ( // Available encodings. var ( // ISO-8859-1. - ENISO = util.Encoding{ + EncodingISO = util.Encoding{ Key: 0, TerminationBytes: []byte{0}, } // UTF-16 encoded Unicode with BOM. - ENUTF16 = util.Encoding{ + EncodingUTF16 = util.Encoding{ Key: 1, TerminationBytes: []byte{0, 0}, } // UTF-16BE encoded Unicode without BOM. - ENUTF16BE = util.Encoding{ + EncodingUTF16BE = util.Encoding{ Key: 2, TerminationBytes: []byte{0, 0}, } // UTF-8 encoded Unicode. - ENUTF8 = util.Encoding{ + EncodingUTF8 = util.Encoding{ Key: 3, TerminationBytes: []byte{0}, } - Encodings = []util.Encoding{ENISO, ENUTF16, ENUTF16BE, ENUTF8} + Encodings = []util.Encoding{EncodingISO, EncodingUTF16, EncodingUTF16BE, EncodingUTF8} ) // Open opens file with name and passes it to OpenFile. diff --git a/tag.go b/tag.go index 78b710e..db2ea4b 100644 --- a/tag.go +++ b/tag.go @@ -191,7 +191,7 @@ func (tag *Tag) Title() string { } func (tag *Tag) SetTitle(title string) { - tag.AddFrame(tag.CommonID("Title/Songname/Content description"), TextFrame{Encoding: ENUTF8, Text: title}) + tag.AddFrame(tag.CommonID("Title/Songname/Content description"), TextFrame{Encoding: EncodingUTF8, Text: title}) } func (tag *Tag) Artist() string { @@ -200,7 +200,7 @@ func (tag *Tag) Artist() string { } func (tag *Tag) SetArtist(artist string) { - tag.AddFrame(tag.CommonID("Lead artist/Lead performer/Soloist/Performing group"), TextFrame{Encoding: ENUTF8, Text: artist}) + tag.AddFrame(tag.CommonID("Lead artist/Lead performer/Soloist/Performing group"), TextFrame{Encoding: EncodingUTF8, Text: artist}) } func (tag *Tag) Album() string { @@ -209,7 +209,7 @@ func (tag *Tag) Album() string { } func (tag *Tag) SetAlbum(album string) { - tag.AddFrame(tag.CommonID("Album/Movie/Show title"), TextFrame{Encoding: ENUTF8, Text: album}) + tag.AddFrame(tag.CommonID("Album/Movie/Show title"), TextFrame{Encoding: EncodingUTF8, Text: album}) } func (tag *Tag) Year() string { @@ -218,7 +218,7 @@ func (tag *Tag) Year() string { } func (tag *Tag) SetYear(year string) { - tag.AddFrame(tag.CommonID("Year"), TextFrame{Encoding: ENUTF8, Text: year}) + tag.AddFrame(tag.CommonID("Year"), TextFrame{Encoding: EncodingUTF8, Text: year}) } func (tag *Tag) Genre() string { @@ -227,7 +227,7 @@ func (tag *Tag) Genre() string { } func (tag *Tag) SetGenre(genre string) { - tag.AddFrame(tag.CommonID("Content type"), TextFrame{Encoding: ENUTF8, Text: genre}) + tag.AddFrame(tag.CommonID("Content type"), TextFrame{Encoding: EncodingUTF8, Text: genre}) } // iterateOverAllFrames iterates over every single frame in tag and calls diff --git a/tag_test.go b/tag_test.go index c6ea81e..bf05648 100644 --- a/tag_test.go +++ b/tag_test.go @@ -28,39 +28,39 @@ const ( var ( frontCover = PictureFrame{ - Encoding: ENUTF8, + Encoding: EncodingUTF8, MimeType: "image/jpeg", PictureType: PTFrontCover, Description: "Front cover", } backCover = PictureFrame{ - Encoding: ENUTF8, + Encoding: EncodingUTF8, MimeType: "image/jpeg", PictureType: PTBackCover, Description: "Back cover", } engUSLF = UnsynchronisedLyricsFrame{ - Encoding: ENUTF8, + Encoding: EncodingUTF8, Language: "eng", ContentDescriptor: "Content descriptor", Lyrics: "bogem/id3v2", } gerUSLF = UnsynchronisedLyricsFrame{ - Encoding: ENUTF8, + Encoding: EncodingUTF8, Language: "ger", ContentDescriptor: "Inhaltsdeskriptor", Lyrics: "Einigkeit und Recht und Freiheit", } engComm = CommentFrame{ - Encoding: ENUTF8, + Encoding: EncodingUTF8, Language: "eng", Description: "Short description", Text: "The actual text", } gerComm = CommentFrame{ - Encoding: ENUTF8, + Encoding: EncodingUTF8, Language: "ger", Description: "Kurze Beschreibung", Text: "Der eigentliche Text", @@ -317,7 +317,7 @@ func TestInvalidLanguageCommentFrame(t *testing.T) { tag := NewEmptyTag() tag.AddCommentFrame(CommentFrame{ - Encoding: ENUTF8, + Encoding: EncodingUTF8, Language: "en", // should be "eng" according to ISO 639-2 Text: "The actual text", }) @@ -339,7 +339,7 @@ func TestInvalidLanguageUSLF(t *testing.T) { tag := NewEmptyTag() tag.AddUnsynchronisedLyricsFrame(UnsynchronisedLyricsFrame{ - Encoding: ENUTF8, + Encoding: EncodingUTF8, Language: "en", // should be "eng" according to ISO 639-2 Lyrics: "Lyrics", }) diff --git a/util/encoding.go b/util/encoding.go index 1f76e59..5f2eb5f 100644 --- a/util/encoding.go +++ b/util/encoding.go @@ -11,7 +11,7 @@ package util // You can set encoding by yourself like this: // // comment := id3v2.CommentFrame{ -// Encoding: id3v2.ENISO, +// Encoding: id3v2.EncodingISO, // Language: "eng", // Description: string([]byte{68, 101, 115, 99}), // Text: string([]byte{84, 101, 120, 116}),