File tree Expand file tree Collapse file tree 5 files changed +29
-16
lines changed
Expand file tree Collapse file tree 5 files changed +29
-16
lines changed Original file line number Diff line number Diff line change 1515 matrix :
1616 os : [ubuntu-latest]
1717 go :
18- - " 1.11"
19- - " 1.12"
20- - " 1.13"
21- - " 1.14"
22- - " 1.15"
23- - " 1.16"
24- - " 1.17"
25- - " 1.18"
26- - " 1.19"
27- - " 1.20"
28- - " 1.21"
29- - " 1.22"
18+ - " >=1.26.0-rc.1"
3019 steps :
3120 - uses : actions/checkout@v6
3221 - name : Set up Go:${{ matrix.go }}
4635 - name : Set up Go
4736 uses : actions/setup-go@v6
4837 with :
49- go-version : " 1.21 "
38+ go-version : " >=1.26.0-rc.1 "
5039 - name : Make check
5140 run : make check
5241 - uses : codecov/codecov-action@v5
Original file line number Diff line number Diff line change 88Package pointer contains helper routines for simplifying the creation
99of optional fields of basic type.
1010
11+ ## Deprecated in Go 1.26+
12+
13+ Starting with ** Go 1.26** , the built-in ` new ` function supports expressions:
14+ ` p := new(42) ` or ` &Age: new(calculateAge()) ` .
15+
16+ This replaces all helpers like ` pointer.Of[Value](v) ` or type-specific ` pointer.Int(1) ` .
17+ ** No need to use this package anymore — copy the generics version locally only if stuck on Go 1.18–1.25.**
18+
1119## A little copying is better than a little dependency
1220
1321With the advent of generics in go 1.18, using this library in your code is
Original file line number Diff line number Diff line change 1+ // Deprecated: Use built-in `new(expr)` in Go 1.26+ instead of pointer helpers.
2+ // See https://tip.golang.org/doc/go1.26#language
13module github.com/xorcare/pointer
24
3- go 1.18
5+ go 1.26
Original file line number Diff line number Diff line change 22// Use of this source code is governed by a BSD-style
33// license that can be found in the LICENSE file.
44
5- //go:build go1.18
6- // +build go1.18
5+ //go:build go1.18 && !go1.26
76
87package pointer
98
Original file line number Diff line number Diff line change 1+ // Copyright © 2022 Vasiliy Vasilyuk. All rights reserved.
2+ // Use of this source code is governed by a BSD-style
3+ // license that can be found in the LICENSE file.
4+
5+ // Deprecated: Use built-in `new(expr)` in Go 1.26+.
6+ // Only for Go 1.18–1.25.
7+ //go:build go1.26
8+
9+ package pointer
10+
11+ // Of is a helper routine that allocates a new any value
12+ // to store v and returns a pointer to it.
13+ func Of [Value any ](v Value ) * Value {
14+ return new (v )
15+ }
You can’t perform that action at this time.
0 commit comments