
Security News
TypeScript is Porting Its Compiler to Go for 10x Faster Builds
TypeScript is porting its compiler to Go, delivering 10x faster builds, lower memory usage, and improved editor performance for a smoother developer experience.
github.com/yinonavraham/go-profiling-demo
Go application for demoing profiling in Go using standard library tools and packages such as pprof
, trace
and expvar
.
This demo was presented in a talk in a Go meetup hosted by AppsFlyer and JFrog on Oct. 19th 2021. The recording (in Hebrew) is available on YouTube. The slides used together with this demo are also available: Web Application Profiling 101 - Slides (pdf)
This is a simple HTTP server application, serving files from a data
directory.
It mainly implements the following endpoint:
GET /file/<file-path>
Following are the steps of this demo. Follow the links to each step to read what is done in the step and to see the code changes.
pprof
endpointsUsing the default serve mux complicates the ability to put access control and enables other packages to expose endpoints implicitly, similar to how the pprof
endpoints are added just by adding an anonymous import.
It is advised to use your own serve mux and add the pprof endpoints explicitly, preferably with an auth middleware.
For example:
func main() {
mux := http.NewServeMux()
mux.HandleFunc("/file/", handleGetFile)
addPprofHandlers(mux)
// ...
log.Fatal(http.ListenAndServe(address, authMiddleware(mux)))
}
func addPprofHandlers(mux *http.ServeMux) {
mux.HandleFunc("/debug/pprof/", pprof.Index)
mux.HandleFunc("/debug/pprof/cmdline", pprof.Cmdline)
mux.HandleFunc("/debug/pprof/symbol", pprof.Symbol)
mux.HandleFunc("/debug/pprof/profile", pprof.Profile)
mux.HandleFunc("/debug/pprof/trace", pprof.Trace)
}
func authMiddleware(next http.Handler) http.Handler {
// ...
}
FAQs
Did you know?
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.
Security News
TypeScript is porting its compiler to Go, delivering 10x faster builds, lower memory usage, and improved editor performance for a smoother developer experience.
Research
Security News
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
Security News
Socket CEO Feross Aboukhadijeh discusses the open web, open source security, and how Socket tackles software supply chain attacks on The Pair Program podcast.