Launch Week Day 5: Introducing Reachability for PHP.Learn More
Socket
Book a DemoSign in
Socket

tildegit.org/sloum/mailcap

Package Overview
Dependencies
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tildegit.org/sloum/mailcap

Go Modules
Version
v0.0.0-20190706214029-b787a49e9db2
Version published
Created
Source

Mailcap

GoDoc

Golang port of the Python3 mailcap library.

Usage

An eaxmple showing how to launch a program based on its mime/media type:

import(
    tildegit.org/sloum/mailcap
)

func main() {
  // Build the mailcap database
  mc := mailcap.NewMailcap()

  // Find an avialable command with the required key and gui avialability
  command, err := mc.FindMatch("text/csv", "edit", false)
  if err != nil {
    panic(err)
  }

  // Run the command with the filepath provided
  err := command.Execute("/var/www/data/some_data.csv")
  if err != nil {
    panic(err)
  }

  // Now that the user has been presented the file to edit,
  // something can be done with the updated file...
}

In general usage a user will build the mailcap db, find a match, and execute the command they find with a certain filepath.

A few other helper methods are available for debugging or lower level mailcap work.

FAQs

Package last updated on 06 Jul 2019

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