Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add stringsext.Join #44

Merged
merged 1 commit into from
Jan 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [5.26.0] - 2024-01-28
### Added
- `stringsext.Join` a more ergonomic way to join strings with a separator when you don't have a slice of strings.

## [5.25.0] - 2024-01-22
### Added
- Add additional `Option.Scan` type support for `sql.Scanner` interface of Uint, Uint16, Uint32, Uint64, Int, Int, Int8, Float32, []byte, json.RawValue.
Expand Down Expand Up @@ -94,7 +98,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- Added `timext.NanoTime` for fast low level monotonic time with nanosecond precision.

[Unreleased]: https://github.com/go-playground/pkg/compare/v5.25.0...HEAD
[Unreleased]: https://github.com/go-playground/pkg/compare/v5.26.0...HEAD
[5.26.0]: https://github.com/go-playground/pkg/compare/v5.25.0..v5.26.0
[5.25.0]: https://github.com/go-playground/pkg/compare/v5.24.0..v5.25.0
[5.24.0]: https://github.com/go-playground/pkg/compare/v5.23.0..v5.24.0
[5.23.0]: https://github.com/go-playground/pkg/compare/v5.22.0..v5.23.0
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# pkg

![Project status](https://img.shields.io/badge/version-5.25.0-green.svg)
![Project status](https://img.shields.io/badge/version-5.26.0-green.svg)
[![Lint & Test](https://github.com/go-playground/pkg/actions/workflows/go.yml/badge.svg)](https://github.com/go-playground/pkg/actions/workflows/go.yml)
[![Coverage Status](https://coveralls.io/repos/github/go-playground/pkg/badge.svg?branch=master)](https://coveralls.io/github/go-playground/pkg?branch=master)
[![GoDoc](https://godoc.org/github.com/go-playground/pkg?status.svg)](https://pkg.go.dev/mod/github.com/go-playground/pkg/v5)
Expand Down
10 changes: 10 additions & 0 deletions strings/join.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package stringsext

import "strings"

// Join is a wrapper around strings.Join with a more ergonomic interface when you don't already have a slice of strings.
//
// Join concatenates the variadic elements placing the separator string between each element.
func Join(sep string, s ...string) string {
return strings.Join(s, sep)
}
14 changes: 14 additions & 0 deletions strings/join_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package stringsext

import (
"strings"
"testing"
)

func TestJoin(t *testing.T) {
s1, s2, s3 := "a", "b", "c"
arr := []string{s1, s2, s3}
if strings.Join(arr, ",") != Join(",", s1, s2, s3) {
t.Errorf("Join failed")
}
}
Loading