add places operations

This commit is contained in:
2026-07-14 01:25:57 +07:00
parent 2b11c49b3c
commit 7a657926f1
12 changed files with 502 additions and 175 deletions
-6
View File
@@ -1,6 +0,0 @@
package formatter
type IFormatter interface {
FormatText(text string) string
FormatString(text string) string
}
@@ -1,17 +1,11 @@
package formatter
package formatter_utils
import (
"bufio"
"strings"
)
type service struct{}
func NewFormatter() IFormatter {
return &service{}
}
func (s *service) FormatText(text string) string {
func FormatText(text string) string {
scanner := bufio.NewScanner(strings.NewReader(text))
scanner.Split(bufio.ScanLines)
@@ -41,7 +35,7 @@ func (s *service) FormatText(text string) string {
return res.String()
}
func (s *service) FormatString(text string) string {
func FormatString(text string) string {
l := strings.TrimSpace(text)
if strings.HasPrefix(l, "--") {
l = strings.Replace(l, "--", "—", 1)
@@ -1,4 +1,4 @@
package formatter
package formatter_utils
import "testing"
@@ -31,8 +31,7 @@ func Test_service_FormatText(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
var s service
got := s.FormatText(tt.text)
got := FormatText(tt.text)
if got != tt.want {
t.Errorf("FormatText() = %v, want %v", got, tt.want)
}