working on auth.
mailer, basic setup with html template and a dev treansport
This commit is contained in:
15
util/open/darwin.go
Normal file
15
util/open/darwin.go
Normal file
@@ -0,0 +1,15 @@
|
||||
//go:build darwin
|
||||
|
||||
package open
|
||||
|
||||
import (
|
||||
"os/exec"
|
||||
)
|
||||
|
||||
func open(input string) *exec.Cmd {
|
||||
return exec.Command("open", input)
|
||||
}
|
||||
|
||||
func openWith(input string, appName string) *exec.Cmd {
|
||||
return exec.Command("open", "-a", appName, input)
|
||||
}
|
17
util/open/linux.go
Normal file
17
util/open/linux.go
Normal file
@@ -0,0 +1,17 @@
|
||||
//go:build linux
|
||||
|
||||
package open
|
||||
|
||||
import (
|
||||
"os/exec"
|
||||
)
|
||||
|
||||
// http://sources.debian.net/src/xdg-utils
|
||||
|
||||
func open(input string) *exec.Cmd {
|
||||
return exec.Command("xdg-open", input)
|
||||
}
|
||||
|
||||
func openWith(input string, appName string) *exec.Cmd {
|
||||
return exec.Command(appName, input)
|
||||
}
|
12
util/open/open.go
Normal file
12
util/open/open.go
Normal file
@@ -0,0 +1,12 @@
|
||||
package open
|
||||
|
||||
// WithDefaultApp open a file, directory, or URI using the OS's default application for that object type.
|
||||
func WithDefaultApp(input string) error {
|
||||
cmd := open(input)
|
||||
return cmd.Run()
|
||||
}
|
||||
|
||||
// WithApp will open a file directory, or URI using the specified application.
|
||||
func App(input string, appName string) error {
|
||||
return openWith(input, appName).Run()
|
||||
}
|
32
util/open/windows.go
Normal file
32
util/open/windows.go
Normal file
@@ -0,0 +1,32 @@
|
||||
//go:build windows
|
||||
|
||||
package open
|
||||
|
||||
import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
)
|
||||
|
||||
var (
|
||||
cmd = "url.dll,FileProtocolHandler"
|
||||
runDll32 = filepath.Join(os.Getenv("SYSTEMROOT"), "System32", "rundll32.exe")
|
||||
)
|
||||
|
||||
func cleaninput(input string) string {
|
||||
r := strings.NewReplacer("&", "^&")
|
||||
return r.Replace(input)
|
||||
}
|
||||
|
||||
func open(input string) *exec.Cmd {
|
||||
cmd := exec.Command(runDll32, cmd, input)
|
||||
// cmd.SysProcAttr = &syscall.SysProcAttr{HideWindow: true}
|
||||
return cmd
|
||||
}
|
||||
|
||||
func openWith(input string, appName string) *exec.Cmd {
|
||||
cmd := exec.Command("cmd", "/C", "start", "", appName, cleaninput(input))
|
||||
// cmd.SysProcAttr = &syscall.SysProcAttr{HideWindow: true}
|
||||
return cmd
|
||||
}
|
Reference in New Issue
Block a user