Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitdd4a944

Browse files
committed
Add OpenBytes function and deprecate FromBytes
Replace FromBytes with OpenBytes for better API discoverability andconsistency with Open(). FromBytes remains as deprecated alias.
1 parentde53e43 commitdd4a944

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

‎CHANGELOG.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
- Improved memory mapping implementation by using`SyscallConn()` instead of
2121
`Fd()` to avoid side effects and prepare for Go 1.25+ Windows I/O
2222
enhancements. Pull request by database64128. GitHub#179.
23+
- Added`OpenBytes` function for better API discoverability and consistency
24+
with`Open()`.`FromBytes` is now deprecated and will be removed in a future
25+
version.
2326

2427
##2.0.0-beta.8 - 2025-07-15
2528

‎reader.go‎

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ func (m Metadata) BuildTime() time.Time {
197197

198198
typereaderOptionsstruct{}
199199

200-
// ReaderOption are options for [Open] and [FromBytes].
200+
// ReaderOption are options for [Open] and [OpenBytes].
201201
//
202202
// This was added to allow for future options, e.g., for caching, without
203203
// causing a breaking API change.
@@ -241,12 +241,12 @@ func Open(file string, options ...ReaderOption) (*Reader, error) {
241241
iferr!=nil {
242242
returnnil,err
243243
}
244-
returnFromBytes(data,options...)
244+
returnOpenBytes(data,options...)
245245
}
246246
returnnil,err
247247
}
248248

249-
reader,err:=FromBytes(data,options...)
249+
reader,err:=OpenBytes(data,options...)
250250
iferr!=nil {
251251
_=munmap(data)
252252
returnnil,err
@@ -290,9 +290,9 @@ func (r *Reader) Close() error {
290290
returnerr
291291
}
292292

293-
//FromBytes takes a byte slice corresponding to a MaxMind DB file and any
293+
//OpenBytes takes a byte slice corresponding to a MaxMind DB file and any
294294
// options. It returns a Reader structure or an error.
295-
funcFromBytes(buffer []byte,options...ReaderOption) (*Reader,error) {
295+
funcOpenBytes(buffer []byte,options...ReaderOption) (*Reader,error) {
296296
opts:=&readerOptions{}
297297
for_,option:=rangeoptions {
298298
option(opts)
@@ -353,6 +353,14 @@ func FromBytes(buffer []byte, options ...ReaderOption) (*Reader, error) {
353353
returnreader,nil
354354
}
355355

356+
// FromBytes takes a byte slice corresponding to a MaxMind DB file and any
357+
// options. It returns a Reader structure or an error.
358+
//
359+
// Deprecated: Use OpenBytes instead. FromBytes will be removed in a future version.
360+
funcFromBytes(buffer []byte,options...ReaderOption) (*Reader,error) {
361+
returnOpenBytes(buffer,options...)
362+
}
363+
356364
// Lookup retrieves the database record for ip and returns a Result, which can
357365
// be used to decode the data.
358366
func (r*Reader)Lookup(ip netip.Addr)Result {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp