-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 for v0.8.0 Release
- Loading branch information
Showing
10 changed files
with
127 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2016-2017 Jeevanandam M., https://myjeeva.com <[email protected]> | ||
Copyright (c) 2016-2018 Jeevanandam M., https://myjeeva.com <[email protected]> | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,20 @@ | ||
# essentials - aah framework | ||
[![Build Status](https://travis-ci.org/go-aah/essentials.svg?branch=master)](https://travis-ci.org/go-aah/essentials) [![codecov](https://codecov.io/gh/go-aah/essentials/branch/master/graph/badge.svg)](https://codecov.io/gh/go-aah/essentials/branch/master) [![Go Report Card](https://goreportcard.com/badge/aahframework.org/essentials.v0)](https://goreportcard.com/report/aahframework.org/essentials.v0) | ||
[![Version](https://img.shields.io/badge/version-0.7-blue.svg)](https://github.com/go-aah/essentials/releases/latest) [![GoDoc](https://godoc.org/aahframework.org/essentials.v0?status.svg)](https://godoc.org/aahframework.org/essentials.v0) [![License](https://img.shields.io/github/license/go-aah/essentials.svg)](LICENSE) | ||
<p align="center"> | ||
<img src="https://cdn.aahframework.org/assets/img/aah-logo-64x64.png" /> | ||
<h2 align="center">Essentials by aah framework</h2> | ||
<p>Essentials contains simple & useful util functions for Go. aah framework utilizes essentials (aka `ess`) library across. Essentials library complements to standard packages, refer Godoc to know more.</p> | ||
</p> | ||
<p align="center"> | ||
<p align="center"><a href="https://travis-ci.org/go-aah/essentials"><img src="https://travis-ci.org/go-aah/essentials.svg?branch=master" alt="Build Status"></a> <a href="https://codecov.io/gh/go-aah/essentials/branch/master"><img src="https://codecov.io/gh/go-aah/essentials/branch/master/graph/badge.svg" alt="Code Coverage"></a> <a href="https://goreportcard.com/report/aahframework.org/essentials.v0"><img src="https://goreportcard.com/badge/aahframework.org/essentials.v0" alt="Go Report Card"></a> <a href="https://github.com/go-aah/essentials/releases/latest"><img src="https://img.shields.io/badge/version-0.8.0-blue.svg" alt="Release Version"></a> <a href="https://godoc.org/aahframework.org/essentials.v0"><img src="https://godoc.org/aahframework.org/essentials.v0?status.svg" alt="Godoc"></a> <a href="https://twitter.com/aahframework"><img src="https://img.shields.io/badge/[email protected]" alt="Twitter @aahframework"></a></p> | ||
</p> | ||
|
||
***v0.7 [released](https://github.com/go-aah/essentials/releases/latest) and tagged on Sep 29, 2017*** | ||
### News | ||
|
||
`essentials` contains simple & useful utils methods for Go. aah framework utilizes essentials (aka `ess`) library across. Essentials library complements with handy methods, refer godoc to know more about methods: | ||
* `v0.8.0` [released](https://github.com/go-aah/essentials/releases/latest) and tagged on Jun 20, 2018. | ||
|
||
* filepath | ||
* GUID (Globally Unique Identifier - Mongo Object ID algorithm) | ||
* random string, random byte generation at fixed length | ||
* go | ||
* io | ||
* os | ||
* reflect | ||
* string | ||
* encode | ||
* archive (zip) | ||
## Installation | ||
|
||
*`essentials` developed for aah framework. However, it's an independent library, can be used separately with any `Go` language project. Feel free to use it.* | ||
|
||
# Installation | ||
#### Stable Version - Production Ready | ||
```sh | ||
# install the library | ||
```bash | ||
go get -u aahframework.org/essentials.v0 | ||
``` | ||
|
||
Visit official website https://aahframework.org to learn more. | ||
Visit official website https://aahframework.org to learn more about `aah` framework. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// Copyright (c) Jeevanandam M. (https://github.com/jeevatkm) | ||
// aahframework.org/essentials source code and usage is governed by a MIT style | ||
// license that can be found in the LICENSE file. | ||
|
||
package ess | ||
|
||
// Valuer interface is general purpose to `Set` and `Get` operations. | ||
type Valuer interface { | ||
Get(key string) interface{} | ||
Set(key string, value interface{}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Copyright (c) Jeevanandam M. (https://github.com/jeevatkm) | ||
// aahframework.org/essentials source code and usage is governed by a MIT style | ||
// license that can be found in the LICENSE file. | ||
|
||
package ess | ||
|
||
import "net/url" | ||
|
||
// IsVaildURL method returns true if given raw URL gets parsed without any errors | ||
// otherwise false. | ||
func IsVaildURL(rawurl string) bool { | ||
_, err := url.Parse(rawurl) | ||
return err == nil | ||
} | ||
|
||
// IsRelativeURL method returns true if given raw URL is relative URL otherwise false. | ||
func IsRelativeURL(rawurl string) bool { | ||
return !IsAbsURL(rawurl) | ||
} | ||
|
||
// IsAbsURL method returns true if given raw URL is absolute URL otherwise false. | ||
func IsAbsURL(rawurl string) bool { | ||
u, err := url.Parse(rawurl) | ||
if err != nil { | ||
return false | ||
} | ||
return u.IsAbs() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// Copyright (c) Jeevanandam M. (https://github.com/jeevatkm) | ||
// aahframework.org/essentials source code and usage is governed by a MIT style | ||
// license that can be found in the LICENSE file. | ||
|
||
package ess | ||
|
||
import ( | ||
"testing" | ||
|
||
"aahframework.org/test.v0/assert" | ||
) | ||
|
||
func TestURLValue(t *testing.T) { | ||
t.Log("Valid URLs") | ||
for _, u := range []string{ | ||
"https://aahframework.org", | ||
"/facebook-auth/callback?code=AQD5-i29_Vn7fNg8VgcV-Uzk_QNO1sx6yO-tJvkRiFaGs1n-wnCxUnvLX0V2q25Tx7JRZAiTds2-DIKrDb8jPEdGquMCedQ_mpMZQxsHmPYeg_cP1Xjy2jHooK-1ZDJZQHXtDSL8FA7r3nVA7WcrCuLZrlrgXq8LnOSAil3oMD-RqPix-nI576GvAPGgiXo6ep_AfS2GaF8A8TOTwl2iwEjB74F23yEukNpz5tmDJVfH02qtrGECuDfaAEPc-4u2wVIIWKCWy3oEEeoEr4zBdzsMtUR1FP3X5yUm0_yAYFP3taAPrpM-5UqtJWmUgaOY-U0&state=72du0BBFIPjW4PsWcI21SccfRX-EkojC4dZ49MYJZac", | ||
"https://www.facebook.com/dialog/oauth?client_id=182958108394860&redirect_uri=http%3A%2F%2Flocalhost%3A8080%2Ffacebook-auth%2Fcallback&response_type=code&scope=public_profile+email&state=72du0BBFIPjW4PsWcI21SccfRX-EkojC4dZ49MYJZac", | ||
"https://godoc.org/golang.org/x/oauth2", | ||
"http://godoc.org/", | ||
} { | ||
assert.True(t, IsVaildURL(u)) | ||
} | ||
|
||
t.Log("Absolute URL") | ||
for _, u := range []string{ | ||
"https://aahframework.org", | ||
"https://www.facebook.com/dialog/oauth?client_id=182958108394860&redirect_uri=http%3A%2F%2Flocalhost%3A8080%2Ffacebook-auth%2Fcallback&response_type=code&scope=public_profile+email&state=72du0BBFIPjW4PsWcI21SccfRX-EkojC4dZ49MYJZac", | ||
"https://godoc.org/golang.org/x/oauth2", | ||
"http://godoc.org/", | ||
} { | ||
assert.True(t, IsAbsURL(u)) | ||
} | ||
|
||
t.Log("Error - Absolute URL") | ||
for _, u := range []string{ | ||
"://aahframework.org", | ||
"://", | ||
"http", | ||
"https", | ||
} { | ||
assert.False(t, IsAbsURL(u)) | ||
} | ||
|
||
t.Log("Relative URL") | ||
for _, u := range []string{ | ||
"/facebook-auth/callback?code=AQD5-i29_Vn7fNg8VgcV-Uzk_QNO1sx6yO-tJvkRiFaGs1n-wnCxUnvLX0V2q25Tx7JRZAiTds2-DIKrDb8jPEdGquMCedQ_mpMZQxsHmPYeg_cP1Xjy2jHooK-1ZDJZQHXtDSL8FA7r3nVA7WcrCuLZrlrgXq8LnOSAil3oMD-RqPix-nI576GvAPGgiXo6ep_AfS2GaF8A8TOTwl2iwEjB74F23yEukNpz5tmDJVfH02qtrGECuDfaAEPc-4u2wVIIWKCWy3oEEeoEr4zBdzsMtUR1FP3X5yUm0_yAYFP3taAPrpM-5UqtJWmUgaOY-U0&state=72du0BBFIPjW4PsWcI21SccfRX-EkojC4dZ49MYJZac", | ||
"/dialog/oauth?client_id=182958108394860&redirect_uri=http%3A%2F%2Flocalhost%3A8080%2Ffacebook-auth%2Fcallback&response_type=code&scope=public_profile+email&state=72du0BBFIPjW4PsWcI21SccfRX-EkojC4dZ49MYJZac", | ||
"/golang.org/x/oauth2", | ||
} { | ||
assert.True(t, IsRelativeURL(u)) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters