Skip to content

Commit 46e6760

Browse files
committed
Remove deprecated opensearch.ToPointer helper
Remove the exported ToPointer generic function and its test. No non-test call sites exist in the tree; internal code uses the unexported per-package ptr helper. Closes #871 Signed-off-by: Arin Mallanna Tumbagi <arin16tumbagi@gmail.com> Signed-off-by: Arin Tumbagi <arin16tumbagi@gmail.com>
1 parent 423763e commit 46e6760

4 files changed

Lines changed: 15 additions & 25 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
205205

206206
### Removed
207207
- Remove backport.yml and dependabot_pr.yml as we are not using backport app anymore
208+
- Remove the deprecated `opensearch.ToPointer` generic helper ([#871](https://github.com/opensearch-project/opensearch-go/issues/871))
208209

209210
### Fixed
210211

UPGRADING.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
- [DiscoverNodes() blocking semantics](#discovernodes-blocking-semantics)
66
- [opensearchtransport.Route interface gained OpID()](#opensearchtransportroute-interface-gained-opid)
77
- [Response.Body becomes a method](#responsebody-becomes-a-method)
8+
- [`opensearch.ToPointer` removed](#opensearchtopointer-removed)
89
- [Upgrading to >= 4.7.0](#upgrading-to->=-4.7.0)
910
- [opensearch.Request interface signature change](#opensearchrequest-interface-signature-change)
1011
- [Path segment values are percent-encoded](#path-segment-values-are-percent-encoded)
@@ -154,6 +155,19 @@ body, err := io.ReadAll(resp.Body())
154155
raw := resp.RawBody()
155156
```
156157

158+
### `opensearch.ToPointer` removed
159+
160+
The deprecated `opensearch.ToPointer` generic helper has been removed. Replace calls with a one-line helper or, on Go 1.26+, use the native `new(value)` form:
161+
162+
```go
163+
// Before
164+
p := opensearch.ToPointer(true)
165+
166+
// After — define a one-line local helper:
167+
func ptr[V any](v V) *V { return &v }
168+
p := ptr(true)
169+
```
170+
157171
## Upgrading to >= 4.7.0
158172

159173
### `opensearch.Request` interface signature change

opensearch.go

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -643,22 +643,3 @@ func extractCredentialsFromURLs(cfg *Config, urls []*url.URL) {
643643
}
644644
}
645645

646-
// ToPointer converts any value to a pointer, mainly used for request parameters
647-
//
648-
// Deprecated: ToPointer will be removed in v5. The helper is intentionally not
649-
// part of the public API going forward; consumers within this module use the
650-
// unexported `ptr` defined per-package. Once the module's go directive moves
651-
// to 1.26, callers can drop any wrapper in favor of the native new(value)
652-
// form (e.g. new(false)).
653-
func ToPointer[V any](value V) *V {
654-
return ptr(value)
655-
}
656-
657-
// ptr returns a pointer to a copy of value. Used for the *T query/body
658-
// parameter pattern. Unexported by design.
659-
//
660-
// Once the module's go directive moves to 1.26, this helper can be deleted
661-
// and call sites can switch to the native new(value) form: new(false).
662-
func ptr[V any](value V) *V {
663-
return &value
664-
}

opensearch_internal_test.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -513,12 +513,6 @@ func TestParseElasticsearchVersion(t *testing.T) {
513513
}
514514
}
515515

516-
func TestToPointer(t *testing.T) {
517-
testPointer := ToPointer(true)
518-
require.NotNil(t, testPointer)
519-
require.True(t, *testPointer)
520-
}
521-
522516
func TestClientGetConfig(t *testing.T) {
523517
t.Run("returns config", func(t *testing.T) {
524518
expectedAddresses := []string{"http://localhost:9200"}

0 commit comments

Comments
 (0)