models

package
v0.0.0-...-878627d Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2020 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type KeywordSet

type KeywordSet struct {
	Keywords  map[string]bool           // the key is the keyword.
	Successes map[string]keywordSuccess // the key is the keyword.
	Fails     map[string]keywordFail    // the key is the keyword.
}

KeywordSet is kind a Set Data Structure implementation. It has an Add method that only works if the Keyword doesn't exist already.

When you use it, firstly create with NewKeywordSet method. Example: k := NewKeywordSet() k.Add(

"boratanrikulu blog yazıları",

)

You can access by using keyword string output, like that: k.Keywords["boratanrikulu blog yazıları"]

func NewKeywordSet

func NewKeywordSet() *KeywordSet

NewKeywordSet inits the KeywordSet to use.

func (*KeywordSet) Add

func (k *KeywordSet) Add(keywords ...string) error

Add method adds new keywords if it is doesn't already exist.

func (*KeywordSet) AddFail

func (k *KeywordSet) AddFail(keyword string, reason string)

AddFail adds the keyword to the fail list with a reason, if it doesn't exist already.

func (*KeywordSet) AddSuccess

func (k *KeywordSet) AddSuccess(keyword string, results []KeywordSuccessResult)

AddSuccess adds the result to the success list, if it doesn't exist already.

func (*KeywordSet) ToStringSlice

func (kw *KeywordSet) ToStringSlice() []string

ToStringSlice create a string slice that includes all Keywords.

type KeywordSuccessResult

type KeywordSuccessResult struct {
	Title string
	Desc  string
	URL   string
}

KeywordSuccessResults keeps the result for success elements. It is exported to use in services package.

type URLSet

type URLSet struct {
	URLs      map[string]url        // the key is url.String() (BaseURL + Keywords).
	Successes map[string]urlSuccess // the key is the Original URL.
	Fails     map[string]urlFail    // the key is the Original URL.
}

URLSet is kind a Set Data Structure implementation. It has an Add method that only works if the URL doesn't exist already. Also, It is able to split the url to FullURL, BaseURL and Keywords. If there is an error, add it to the fail list. (only adds when the fail info doesn't exist already.)

When you use it, firstly create with NewURLSet method. Example: s := NewURLSet() s.Add(

	 "https://boratanrikulu.dev/postgresql-nedir-nasil-calisir/",
  "https://boratanrikulu.dev/smtp-nasil-calisir-ve-postfix-kurulumu/",

)

You can access by using string output, like that: s.URLs["boratanrikulu.dev postgresql nedir nasil calisir"].BaseURL

func NewURLSet

func NewURLSet() *URLSet

NewURLSet inits the URLSet to use.

func (*URLSet) Add

func (s *URLSet) Add(urls ...string)

Add method adds new URLs if it is doesn't exist already. Also, It splits the url to FullURL, BaseURL and Keywords. It except only valid URLs. If there is an issue with the given URL, It adds it to the fail list with a reason.

func (*URLSet) AddFail

func (s *URLSet) AddFail(originalURL string, reason string)

AddFail adds the url to the fail list with a reason, if it doesn't exist already.

func (*URLSet) AddSuccess

func (s *URLSet) AddSuccess(originalURL string, result []string)

AddSuccess adds the result to the success list, if it doesn't exist already.

func (*URLSet) ToStringSlice

func (u *URLSet) ToStringSlice() []string

ToStringSlice create a string slice that includes all URLs.

Jump to

Keyboard shortcuts

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