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

git.sr.ht/~mariusor/assets/examples/004-minified-fs

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

git.sr.ht/~mariusor/assets/examples/004-minified-fs

  • v0.0.0-20230127131019-f411b9009e81
  • Go
  • Socket score

Version published
Created
Source

This is an example that's more elaborate and closer to real world use cases corresponding to a web application.

We have a ./static folder which contains all multiple types of files, CSS styles, JavaScript files, an SVG document and some other plain text or binary resources.

For the stylesheets, JavaScript files and the SVG document we want to minify them before using them as a assets in our binary.

Because //go:embed doesn't support adding functionality into the embed pipeline, we are forced to create our own generator, which creates a fs.FS compatible object, that we map our assets group on top of.

To use this example:

# the minify warnings can be ignored, the undeclared mount variable is what the script eventually generates
go generate main.go
minify: checking package: main.go:12:32: undeclared name: mount
minify: proceeding anyway...

go run main.go
2022/08/05 14:11:06 [GET] /main.js 3.006738ms

Load one file:

# since the example files are very simple, the only hint that they have
# been minified is the fact that there's no new line between the 
# two function calls.
curl http://localhost:6699/main.js
console.log("Hello!!!");console.error("Minification!!");

FAQs

Package last updated on 27 Jan 2023

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