Skip to content

Commit

Permalink
refactor: Use a slice of pointers for exports to allow swapping backe…
Browse files Browse the repository at this point in the history
…nds at later points
  • Loading branch information
pojntfx committed Aug 8, 2023
1 parent 72b3d30 commit 9a16d1a
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion cmd/go-nbd-example-server-file/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func main() {

if err := server.Handle(
conn,
[]server.Export{
[]*server.Export{
{
Name: *name,
Description: *description,
Expand Down
2 changes: 1 addition & 1 deletion cmd/go-nbd-example-server-memory/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func main() {

if err := server.Handle(
conn,
[]server.Export{
[]*server.Export{
{
Name: *name,
Description: *description,
Expand Down
4 changes: 2 additions & 2 deletions pkg/server/nbd.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ type Options struct {
MaximumBlockSize uint32
}

func Handle(conn net.Conn, exports []Export, options *Options) error {
func Handle(conn net.Conn, exports []*Export, options *Options) error {
if options == nil {
options = &Options{
ReadOnly: false,
Expand Down Expand Up @@ -93,7 +93,7 @@ n:

for _, candidate := range exports {
if candidate.Name == string(exportName) {
export = &candidate
export = candidate

break
}
Expand Down

0 comments on commit 9a16d1a

Please sign in to comment.