swapi

package
v0.0.0-...-8e05508 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 8, 2021 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Overview

swapi package implements some object types that are manipulated by our hypothetical API used for this experiment and exposes a Port (interface) for a repository of those objects, as well as a simple in-memory Adapter (implementation) of that repository.

Index

Constants

This section is empty.

Variables

View Source
var TestCharacters = []Character{
	{
		Name:           "Luke Skywalker",
		Height:         172,
		Mass:           77,
		HairColor:      "blond",
		Gender:         "male",
		ForceSensitive: true,
		Ghost:          true,
		Tags:           []string{"human", "jedi", "rebel", "starfighter-pilot", "shuttle-pilot", "green-lightsaber"},
	},
	{
		Name:           "C-3PO",
		Height:         167,
		Mass:           75,
		HairColor:      "n/a",
		Gender:         "n/a",
		ForceSensitive: false,
		Ghost:          false,
		Tags:           []string{"droid"},
	},
	{
		Name:           "R2-D2",
		Height:         96,
		Mass:           32,
		HairColor:      "n/a",
		Gender:         "n/a",
		ForceSensitive: false,
		Ghost:          false,
		Tags:           []string{"droid"},
	},
	{
		Name:           "Darth Vader",
		Height:         202,
		Mass:           136,
		HairColor:      "none",
		Gender:         "male",
		ForceSensitive: true,
		Ghost:          true,
		Tags:           []string{"human", "sith", "empire", "tie-pilot", "crimson-lightsaber"},
	},
	{
		Name:           "Leia Organa",
		Height:         150,
		Mass:           49,
		HairColor:      "brown",
		Gender:         "female",
		ForceSensitive: true,
		Ghost:          false,
		Tags:           []string{"human", "general", "rebel"},
	},
	{
		Name:           "Obi-Wan Kenobi",
		Height:         182,
		Mass:           77,
		HairColor:      "white",
		Gender:         "male",
		ForceSensitive: true,
		Ghost:          true,
		Tags:           []string{"human", "jedi", "starfighter-pilot", "medium-blue-lightsaber"},
	},
	{
		Name:           "Chewbacca",
		Height:         228,
		Mass:           112,
		HairColor:      "brown",
		Gender:         "male",
		ForceSensitive: false,
		Ghost:          false,
		Tags:           []string{"wookie", "smuggler", "freighter-pilot"},
	},
	{
		Name:           "Han Solo",
		Height:         180,
		Mass:           80,
		HairColor:      "brown",
		Gender:         "male",
		ForceSensitive: false,
		Ghost:          true,
		Tags:           []string{"human", "smuggler", "freighter-pilot"},
	},
	{
		Name:           "Yoda",
		Height:         66,
		Mass:           17,
		HairColor:      "white",
		Gender:         "male",
		ForceSensitive: true,
		Ghost:          true,
		Tags:           []string{"jedi", "green-lightsaber"},
	},
}

TestCharacters is a list of sample Character objects, taken mostly from https://swapi.dev/ and https://starwars.fandom.com/

Functions

func NewInMemoryRepository

func NewInMemoryRepository() *inMemoryRepository

NewInMemoryRepository factory for in-memory repository

Types

type Character

type Character struct {
	Name           string
	Height         int
	Mass           int
	HairColor      string
	Gender         string
	ForceSensitive bool
	Ghost          bool
	Tags           []string
}

type Port

type Port interface {
	GetAll() ([]Character, error)
}

Port of the SW-API data backend

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL