Skip to content

Instantly share code, notes, and snippets.

@ichtrojan
Created January 14, 2023 06:29
Show Gist options
  • Save ichtrojan/863aa7c5aca6760e1fb150c4b097284a to your computer and use it in GitHub Desktop.
Save ichtrojan/863aa7c5aca6760e1fb150c4b097284a to your computer and use it in GitHub Desktop.
package helpers
import (
"fmt"
"math"
"strings"
)
func HideEmail(email string) string {
em := strings.Split(email, "@")
name := strings.Join(em[0:len(em)-1], "@")
lenght := math.Floor(float64(len(name) / 2))
return fmt.Sprintf("%s%s@%s", name[:int(lenght)], strings.Repeat("*", int(lenght)), em[len(em)-1])
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment