Package besticon includes functions finding icons for a given web site.



    View Source
    const MaxIconSize = 500

      TODO: Turn into env var:

      View Source
      const MinIconSize = 0
      View Source
      const VersionString = "v3.12.0"

        Version string, same as VERSION, generated my Make


        View Source
        var BuildDate string // set via ldflags on Make
        View Source
        var PopularSites []string

          PopularSites we might use for examples and testing.


          func CacheEnabled

          func CacheEnabled() bool

          func Get

          func Get(urlstring string) (*http.Response, error)

          func GetBodyBytes

          func GetBodyBytes(r *http.Response) ([]byte, error)

          func GetCacheStats

          func GetCacheStats() groupcache.CacheStats

            GetCacheStats returns cache statistics.

            func MainColorForIcons

            func MainColorForIcons(icons []Icon) *color.RGBA

            func SetCacheMaxSize

            func SetCacheMaxSize(sizeInMB int64)

              SetCacheMaxSize enables icon caching if sizeInMB > 0.

              func SetLogOutput

              func SetLogOutput(w io.Writer)

                SetLogOutput sets the output for the package's logger.


                type Icon

                type Icon struct {
                	URL       string `json:"url"`
                	Width     int    `json:"width"`
                	Height    int    `json:"height"`
                	Format    string `json:"format"`
                	Bytes     int    `json:"bytes"`
                	Error     error  `json:"error"`
                	Sha1sum   string `json:"sha1sum"`
                	ImageData []byte `json:",omitempty"`

                  Icon holds icon information.

                  func (*Icon) Image

                  func (ico *Icon) Image() (*image.Image, error)

                  type IconFinder

                  type IconFinder struct {
                  	FormatsAllowed  []string
                  	HostOnlyDomains []string
                  	KeepImageBytes  bool
                  	// contains filtered or unexported fields

                  func (*IconFinder) FetchIcons

                  func (f *IconFinder) FetchIcons(url string) ([]Icon, error)

                  func (*IconFinder) IconInSizeRange

                  func (f *IconFinder) IconInSizeRange(r SizeRange) *Icon

                  func (*IconFinder) Icons

                  func (f *IconFinder) Icons() []Icon

                  func (*IconFinder) MainColorForIcons

                  func (f *IconFinder) MainColorForIcons() *color.RGBA

                  type SizeRange

                  type SizeRange struct {
                  	Min     int
                  	Perfect int
                  	Max     int

                    SizeRange represents the desired icon dimensions

                    func ParseSizeRange

                    func ParseSizeRange(s string) (*SizeRange, error)

                      ParseSizeRange parses a string like 60..100..200 into a SizeRange


                      Path Synopsis