-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: substituted format structs by global variables
- Loading branch information
1 parent
e24abf2
commit 3038a94
Showing
4 changed files
with
141 additions
and
222 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package separator | ||
|
||
import ( | ||
"strings" | ||
) | ||
|
||
type ( | ||
// Separator is the separator for a string | ||
Separator string | ||
|
||
// Content is the separator for the content | ||
Content struct { | ||
Left Separator | ||
Right Separator | ||
} | ||
|
||
// Multiline is the separator for the multiline content | ||
Multiline struct { | ||
SingleLine Separator | ||
Line Separator | ||
TabSize int | ||
} | ||
) | ||
|
||
// Separator constants | ||
const ( | ||
Space Separator = " " | ||
Comma Separator = "," | ||
NewLine Separator = "\n" | ||
Tab Separator = "\t" | ||
) | ||
|
||
// NewContent creates a new content separator | ||
func NewContent(left, right Separator) *Content { | ||
return &Content{ | ||
Left: left, | ||
Right: right, | ||
} | ||
} | ||
|
||
// NewRepeatedContent creates a new content separator with the same separator | ||
func NewRepeatedContent(separator Separator) *Content { | ||
return NewContent(separator, separator) | ||
} | ||
|
||
// NewMultiline creates a new multiline separator | ||
func NewMultiline( | ||
singleLine, line Separator, | ||
tabSize int, | ||
) *Multiline { | ||
return &Multiline{ | ||
SingleLine: singleLine, | ||
Line: line, | ||
TabSize: tabSize, | ||
} | ||
} | ||
|
||
// Tab returns a tab separator | ||
func (m *Multiline) Tab() Separator { | ||
return Separator(strings.Repeat(string(Tab), m.TabSize)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.