-
-
Save hjr265/956b3b39df8227adef34 to your computer and use it in GitHub Desktop.
Too Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package too_test | |
import ( | |
"fmt" | |
"log" | |
"net" | |
"github.com/hjr265/too" | |
) | |
func ExampleEngine() { | |
redisAddr, _ := net.ResolveTCPAddr("tcp", ":6379") | |
te, err := too.New(redisAddr, "movies") | |
if err != nil { | |
log.Fatal(err) | |
} | |
te.Likes.Add("Sonic", "The Shawshank Redemption") | |
te.Likes.Add("Sonic", "The Godfather") | |
te.Likes.Add("Sonic", "The Dark Knight") | |
te.Likes.Add("Sonic", "Pulp Fiction") | |
te.Likes.Add("Mario", "The Godfather") | |
te.Likes.Add("Mario", "The Dark Knight") | |
te.Likes.Add("Mario", "The Shawshank Redemption") | |
te.Likes.Add("Mario", "The Prestige") | |
te.Likes.Add("Mario", "The Matrix") | |
te.Likes.Add("Peach", "The Godfather") | |
te.Likes.Add("Peach", "Inception") | |
te.Likes.Add("Peach", "Fight Club") | |
te.Likes.Add("Peach", "WALL·E") | |
te.Likes.Add("Peach", "Princess Mononoke") | |
te.Likes.Add("Luigi", "The Prestige") | |
te.Likes.Add("Luigi", "The Dark Knight") | |
items, _ := te.Suggestions.For("Luigi", 2) | |
for _, item := range items { | |
fmt.Println(item) | |
} | |
// Output: | |
// The Shawshank Redemption | |
// The Matrix | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment