Skip to content

Commit 9a16d1a

Browse files
committed
refactor: Use a slice of pointers for exports to allow swapping backends at later points
1 parent 72b3d30 commit 9a16d1a

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

cmd/go-nbd-example-server-file/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ func main() {
7575

7676
if err := server.Handle(
7777
conn,
78-
[]server.Export{
78+
[]*server.Export{
7979
{
8080
Name: *name,
8181
Description: *description,

cmd/go-nbd-example-server-memory/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ func main() {
6060

6161
if err := server.Handle(
6262
conn,
63-
[]server.Export{
63+
[]*server.Export{
6464
{
6565
Name: *name,
6666
Description: *description,

pkg/server/nbd.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ type Options struct {
3434
MaximumBlockSize uint32
3535
}
3636

37-
func Handle(conn net.Conn, exports []Export, options *Options) error {
37+
func Handle(conn net.Conn, exports []*Export, options *Options) error {
3838
if options == nil {
3939
options = &Options{
4040
ReadOnly: false,
@@ -93,7 +93,7 @@ n:
9393

9494
for _, candidate := range exports {
9595
if candidate.Name == string(exportName) {
96-
export = &candidate
96+
export = candidate
9797

9898
break
9999
}

0 commit comments

Comments
 (0)