diff --git a/Gopkg.lock b/Gopkg.lock index a4b3c00..d1382cb 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -25,6 +25,12 @@ revision = "76626ae9c91c4f2a10f34cad8ce83ea42c93bb75" version = "v1.0" +[[projects]] + name = "github.com/mattn/go-encoding" + packages = ["."] + revision = "a934bb263954cae0fe21b222a60076d4e344c149" + version = "v0.0.2" + [[projects]] name = "github.com/mattn/go-isatty" packages = ["."] @@ -37,12 +43,6 @@ revision = "645ef00459ed84a119197bfb8d8205042c6df63d" version = "v0.8.0" -[[projects]] - branch = "master" - name = "github.com/saintfish/chardet" - packages = ["."] - revision = "3af4cd4741ca4f3eb0c407c034571a6fb0ea529c" - [[projects]] name = "github.com/spf13/cobra" packages = ["."] @@ -61,16 +61,10 @@ revision = "d80ff117c2cb7e41be5605ede6291c43d7b2e397" version = "v0.4.4" -[[projects]] - name = "github.com/spiegel-im-spiegel/text" - packages = ["decode","detect"] - revision = "e9ec92711bcb137393b35a62997b36c33b729e67" - version = "v0.1.0" - [[projects]] branch = "master" name = "golang.org/x/net" - packages = ["html","html/atom"] + packages = ["html","html/atom","html/charset"] revision = "a8b9294777976932365dabb6640cf1468d95c70f" [[projects]] @@ -82,12 +76,12 @@ [[projects]] branch = "master" name = "golang.org/x/text" - packages = ["encoding","encoding/internal","encoding/internal/identifier","encoding/japanese","encoding/korean","encoding/simplifiedchinese","encoding/traditionalchinese","internal/gen","transform","unicode/cldr"] + packages = ["encoding","encoding/charmap","encoding/htmlindex","encoding/internal","encoding/internal/identifier","encoding/japanese","encoding/korean","encoding/simplifiedchinese","encoding/traditionalchinese","encoding/unicode","internal/gen","internal/tag","internal/utf8internal","language","runes","transform","unicode/cldr"] revision = "556d234e9c5239918de4d1fe247d1fe004e71764" [solve-meta] analyzer-name = "dep" analyzer-version = 1 - inputs-digest = "227cf7889bfd61f47873d26bda340822a361887c81b57d145b375704cc77d143" + inputs-digest = "43ad2649e06c0e56eb5256726e1afc9cf33a826df27fa9c08691c5340fa2aa03" solver-name = "gps-cdcl" solver-version = 1 diff --git a/Gopkg.toml b/Gopkg.toml index 4549db4..4f42842 100644 --- a/Gopkg.toml +++ b/Gopkg.toml @@ -20,17 +20,6 @@ # name = "github.com/x/y" # version = "2.4.0" -ignored = [ - "github.com/cpuguy83/go-md2man/md2man", - "github.com/mitchellh/go-homedir", - "github.com/russross/blackfriday", - "github.com/spf13/cobra/cobra", - "github.com/spf13/cobra/cobra/cmd", - "github.com/spf13/cobra/doc", - "github.com/spf13/viper", - "gopkg.in/yaml.v2", -] - [[constraint]] name = "github.com/spf13/cobra" version = "~0.0.1" @@ -39,10 +28,6 @@ ignored = [ name = "github.com/spiegel-im-spiegel/gocli" version = "~0.4.0" -[[constraint]] - name = "github.com/spiegel-im-spiegel/text" - version = "~0.1.0" - [[constraint]] name = "github.com/pkg/errors" version = "~0.8.0" diff --git a/dependency.png b/dependency.png index 30cdb5e..eb4b313 100644 Binary files a/dependency.png and b/dependency.png differ diff --git a/mklink.go b/mklink.go index 93178a0..9616cc5 100644 --- a/mklink.go +++ b/mklink.go @@ -38,9 +38,11 @@ func New(url string) (*Link, error) { br := bufio.NewReader(resp.Body) var r io.Reader = br - //if data, err2 := br.Peek(1024); err2 == nil { //next 1024 bytes without advancing the reader. - if data, _ := br.Peek(4024); len(data) > 0 { //next 1024 bytes without advancing the reader. - if _, name, ok := charset.DetermineEncoding(data, resp.Header.Get("content-type")); ok { + if data, err2 := br.Peek(1024); err2 == nil { //next 1024 bytes without advancing the reader. + enc, name, _ := charset.DetermineEncoding(data, resp.Header.Get("content-type")) + if enc != nil { + r = enc.NewDecoder().Reader(br) + } else if len(name) > 0 { if enc := encoding.GetEncoding(name); enc != nil { r = enc.NewDecoder().Reader(br) }