Skip to content

Instantly share code, notes, and snippets.

View Crazy3lf's full-sized avatar
👹
Always evil sometimes.

FuXiang Shu Crazy3lf

👹
Always evil sometimes.
  • Selangor, Malaysia
View GitHub Profile
@Crazy3lf
Crazy3lf / .env
Last active July 3, 2019 02:26
Handling .env file with option to override them with flags. This example read .env into a map instead of writing into the OS environment variables.
AMI_USERNAME="YOUR_AMI_USERNAME"
AMI_PASSWORD="YOUR_AMI_PASSWORD"
AMI_HOST="YOUR_AMI_HOST"
package email
import (
"testing"
)
func TestIsValidEmail(t *testing.T) {
testCases := []struct {
name string
email string
func isValidEmail(Value string) (result bool) {
result = false
var checkAllowed = regexp.MustCompile(`^[a-zA-z0-9_\-.+]+$`).MatchString
i := strings.Index(Value, `@`)
if i < 1 {
return
}
if strings.Contains(Value, `..`) || strings.Contains(Value, `@@`) || strings.Contains(Value, `.@`) {
return