Skip to content

Commit ae673dd

Browse files
author
Dean Karn
authored
add stringsext.Join (#44)
1 parent 1a0a47d commit ae673dd

File tree

4 files changed

+31
-2
lines changed

4 files changed

+31
-2
lines changed

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased]
88

9+
## [5.26.0] - 2024-01-28
10+
### Added
11+
- `stringsext.Join` a more ergonomic way to join strings with a separator when you don't have a slice of strings.
12+
913
## [5.25.0] - 2024-01-22
1014
### Added
1115
- Add additional `Option.Scan` type support for `sql.Scanner` interface of Uint, Uint16, Uint32, Uint64, Int, Int, Int8, Float32, []byte, json.RawValue.
@@ -94,7 +98,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
9498
### Added
9599
- Added `timext.NanoTime` for fast low level monotonic time with nanosecond precision.
96100

97-
[Unreleased]: https://github.com/go-playground/pkg/compare/v5.25.0...HEAD
101+
[Unreleased]: https://github.com/go-playground/pkg/compare/v5.26.0...HEAD
102+
[5.26.0]: https://github.com/go-playground/pkg/compare/v5.25.0..v5.26.0
98103
[5.25.0]: https://github.com/go-playground/pkg/compare/v5.24.0..v5.25.0
99104
[5.24.0]: https://github.com/go-playground/pkg/compare/v5.23.0..v5.24.0
100105
[5.23.0]: https://github.com/go-playground/pkg/compare/v5.22.0..v5.23.0

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# pkg
22

3-
![Project status](https://img.shields.io/badge/version-5.25.0-green.svg)
3+
![Project status](https://img.shields.io/badge/version-5.26.0-green.svg)
44
[![Lint & Test](https://github.com/go-playground/pkg/actions/workflows/go.yml/badge.svg)](https://github.com/go-playground/pkg/actions/workflows/go.yml)
55
[![Coverage Status](https://coveralls.io/repos/github/go-playground/pkg/badge.svg?branch=master)](https://coveralls.io/github/go-playground/pkg?branch=master)
66
[![GoDoc](https://godoc.org/github.com/go-playground/pkg?status.svg)](https://pkg.go.dev/mod/github.com/go-playground/pkg/v5)

strings/join.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package stringsext
2+
3+
import "strings"
4+
5+
// Join is a wrapper around strings.Join with a more ergonomic interface when you don't already have a slice of strings.
6+
//
7+
// Join concatenates the variadic elements placing the separator string between each element.
8+
func Join(sep string, s ...string) string {
9+
return strings.Join(s, sep)
10+
}

strings/join_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package stringsext
2+
3+
import (
4+
"strings"
5+
"testing"
6+
)
7+
8+
func TestJoin(t *testing.T) {
9+
s1, s2, s3 := "a", "b", "c"
10+
arr := []string{s1, s2, s3}
11+
if strings.Join(arr, ",") != Join(",", s1, s2, s3) {
12+
t.Errorf("Join failed")
13+
}
14+
}

0 commit comments

Comments
 (0)