Skip to content

Commit

Permalink
add stringsext.Join (#44)
Browse files Browse the repository at this point in the history
  • Loading branch information
deankarn authored Jan 28, 2024
1 parent 1a0a47d commit ae673dd
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 2 deletions.
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")
}
}

0 comments on commit ae673dd

Please sign in to comment.