Skip to content

How do you use this? is there a main.go code I can reference? #2

@unisqu

Description

@unisqu

I'm trying to try to code but have no idea how to use. Can you please provide the instructions? I've configure make install judy c code. but these codes doesnt run. it says

./main.go:5: imported and not used: "github.com/gnoso/go-judy" as judy
./main.go:16: j.Free undefined (type JudyL has no field or method Free)
./main.go:17: j.Insert undefined (type JudyL has no field or method Insert)
./main.go:18: j.Get undefined (type JudyL has no field or method Get)
./main.go:19: j.Get undefined (type JudyL has no field or method Get)
./main.go:20: j.Delete undefined (type JudyL has no field or method Delete)
./main.go:21: j.Delete undefined (type JudyL has no field or method Delete)

pls help.

package main

import (
                "fmt"
                "github.com/gnoso/go-judy"
       )

type JudyL struct {
    // contains filtered or unexported fields
    uid uint32

}
//var judy JudyL;
func main() {
j := JudyL{} // declare empty JudyL integer map array
   defer j.Free() // make sure the array is freed when finished
           j.Insert(11235, 1123)   // returns true
           val, ok := j.Get(11235) // val == 1123, ok == true
           _, ok = j.Get(1) // ok == false (not found)
           j.Delete(11235) // returns true
           j.Delete(11235) // returns false (doesn't exist)
           fmt.Printf("Hello world! My lucky number is %d", val)

}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions