Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

github.com/sqweek/dialog

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/sqweek/dialog

  • v0.0.0-20240226140203-065105509627
  • Source
  • Go
  • Socket score

Version published
Created
Source

dialog

Simple cross-platform dialog API for go-lang

examples

ok := dialog.Message("%s", "Do you want to continue?").Title("Are you sure?").YesNo()

Creates a dialog box titled "Are you sure?", containing the message "Do you want to continue?", a "Yes" button and a "No" button. Returns true iff the dialog could be displayed and the user pressed the "Yes" button.

filename, err := dialog.File().Filter("Mp3 audio file", "mp3").Load()

Creates a file selection dialog allowing the user to select a .mp3 file. The absolute path of the file is returned, unless an error is encountered or the user cancels/closes the dialog. In the latter case, filename will be the empty string and err will equal dialog.Cancelled.

filename, err := dialog.File().Filter("XML files", "xml").Title("Export to XML").Save()

Asks the user for a filename to write data into. If the user selects a file which already exists, an additional dialog is spawned to confirm they want to overwrite the existing file.

directory, err := dialog.Directory().Title("Load images").Browse()

Asks the user for a directory.

platform details

  • OSX: uses Cocoa's NSAlert/NSSavePanel/NSOpenPanel/NSApp classes
    • requires macOS 10.6+ for NSApplicationActivationPolicyAccessory
  • Win32: uses MessageBox/GetOpenFileName/GetSaveFileName (via package github.com/TheTitanrain/w32)
  • Linux: uses Gtk's MessageDialog/FileChooserDialog (via cgo; requires gtk3 development packages)

build

go mod download
go build

bugs

On windows, the Load() and Save() calls change the working directory for the whole process while the dialog is open (after which it reset). This is an apparently unavoidable side effect of the underlying W32API; see #63 for more details.

FAQs

Package last updated on 26 Feb 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc