Hello community, here is the log from the commit of package go-goauth2 for openSUSE:Factory checked in at 2012-02-14 11:24:16 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/go-goauth2 (Old) and /work/SRC/openSUSE:Factory/.go-goauth2.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "go-goauth2", Maintainer is "" Changes: -------- --- /work/SRC/openSUSE:Factory/go-goauth2/go-goauth2.changes 2012-01-19 09:41:49.000000000 +0100 +++ /work/SRC/openSUSE:Factory/.go-goauth2.new/go-goauth2.changes 2012-02-14 11:24:18.000000000 +0100 @@ -1,0 +2,5 @@ +Fri Feb 3 05:52:59 UTC 2012 - [email protected] + +- gofixes for latest + +------------------------------------------------------------------- Old: ---- goauth2-weekly-fixes.patch New: ---- opensuse-build-fix.patch ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ go-goauth2.spec ++++++ --- /var/tmp/diff_new_pack.Htyu2X/_old 2012-02-14 11:24:20.000000000 +0100 +++ /var/tmp/diff_new_pack.Htyu2X/_new 2012-02-14 11:24:20.000000000 +0100 @@ -1,7 +1,7 @@ # # spec file for package go-goauth2 # -# Copyright (c) 2011 SUSE LINUX Products GmbH, Nuernberg, Germany. +# Copyright (c) 2012 SUSE LINUX Products GmbH, Nuernberg, Germany. # Copyright (c) 2011 Sascha Peilicke <[email protected]> # # All modifications and additions to the file contributed by third parties @@ -17,6 +17,7 @@ # + Name: go-goauth2 Version: 0.0.0+hg20111205 Release: 0 @@ -25,7 +26,7 @@ Group: Development/Languages/Other Url: http://code.google.com/p/goauth2/ Source0: goauth2-%{version}.tar.bz2 -Patch0: goauth2-weekly-fixes.patch +Patch0: opensuse-build-fix.patch BuildRoot: %{_tmppath}/%{name}-%{version}-build BuildRequires: go-devel %{go_provides} @@ -42,7 +43,7 @@ %build %install -cd oauth && %{go_make_install} +%goinstall code.google.com/p/goauth2 oauth %files %defattr(-,root,root,-) ++++++ goauth2-0.0.0+hg20111205.tar.bz2 ++++++ ++++++ opensuse-build-fix.patch ++++++ diff --git a/oauth/example/buzz.go b/oauth/example/buzz.go index c46206b..8676807 100644 --- a/oauth/example/buzz.go +++ b/oauth/example/buzz.go @@ -11,8 +11,7 @@ import ( "io" "log" "os" - - "goauth2.googlecode.com/hg/oauth" + "code.google.com/p/goauth2/oauth" ) var ( diff --git a/oauth/oauth.go b/oauth/oauth.go index 9e2d575..d82a0e3 100644 --- a/oauth/oauth.go +++ b/oauth/oauth.go @@ -40,11 +40,11 @@ package oauth // TODO(adg): A means of automatically saving credentials when updated. import ( - "http" - "json" - "os" + "encoding/json" + "errors" + "net/http" + "net/url" "time" - "url" ) // Config is the configuration of an OAuth consumer. @@ -81,7 +81,7 @@ func (t *Token) Expired() bool { if t.TokenExpiry == 0 { return false } - return t.TokenExpiry <= time.Seconds() + return t.TokenExpiry <= time.Now().Unix() } // Transport implements http.RoundTripper. When configured with a valid @@ -121,7 +121,7 @@ func (t *Transport) transport() http.RoundTripper { func (c *Config) AuthCodeURL(state string) string { url_, err := url.Parse(c.AuthURL) if err != nil { - panic("AuthURL malformed: " + err.String()) + panic("AuthURL malformed: " + err.Error()) } q := url.Values{ "response_type": {"code"}, @@ -139,9 +139,9 @@ func (c *Config) AuthCodeURL(state string) string { } // Exchange takes a code and gets access Token from the remote server. -func (t *Transport) Exchange(code string) (tok *Token, err os.Error) { +func (t *Transport) Exchange(code string) (tok *Token, err error) { if t.Config == nil { - return nil, os.NewError("no Config supplied") + return nil, errors.New("no Config supplied") } tok = new(Token) err = t.updateToken(tok, url.Values{ @@ -164,12 +164,12 @@ func (t *Transport) Exchange(code string) (tok *Token, err os.Error) { // If the Token cannot be renewed a non-nil os.Error value will be returned. // If the Token is invalid callers should expect HTTP-level errors, // as indicated by the Response's StatusCode. -func (t *Transport) RoundTrip(req *http.Request) (*http.Response, os.Error) { +func (t *Transport) RoundTrip(req *http.Request) (*http.Response, error) { if t.Config == nil { - return nil, os.NewError("no Config supplied") + return nil, errors.New("no Config supplied") } if t.Token == nil { - return nil, os.NewError("no Token supplied") + return nil, errors.New("no Token supplied") } // Refresh the Token if it has expired. @@ -185,11 +185,11 @@ func (t *Transport) RoundTrip(req *http.Request) (*http.Response, os.Error) { } // Refresh renews the Transport's AccessToken using its RefreshToken. -func (t *Transport) Refresh() os.Error { +func (t *Transport) Refresh() error { if t.Config == nil { - return os.NewError("no Config supplied") + return errors.New("no Config supplied") } else if t.Token == nil { - return os.NewError("no exisiting Token") + return errors.New("no exisiting Token") } return t.updateToken(t.Token, url.Values{ @@ -198,7 +198,7 @@ func (t *Transport) Refresh() os.Error { }) } -func (t *Transport) updateToken(tok *Token, v url.Values) os.Error { +func (t *Transport) updateToken(tok *Token, v url.Values) error { v.Set("client_id", t.ClientId) v.Set("client_secret", t.ClientSecret) r, err := (&http.Client{Transport: t.transport()}).PostForm(t.TokenURL, v) @@ -207,13 +207,13 @@ func (t *Transport) updateToken(tok *Token, v url.Values) os.Error { } defer r.Body.Close() if r.StatusCode != 200 { - return os.NewError("invalid response: " + r.Status) + return errors.New("invalid response: " + r.Status) } if err = json.NewDecoder(r.Body).Decode(tok); err != nil { return err } if tok.TokenExpiry != 0 { - tok.TokenExpiry = time.Seconds() + tok.TokenExpiry + tok.TokenExpiry = time.Now().Unix() + tok.TokenExpiry } return nil } -- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
