main.go1186 chars50 lines
This code creates an HTTP server in Go that listens on port 8080, and captures a file using a form and saves it to the current directory. The HTTP server is created using the http
package built into Go. A function uploadFile
is defined which handles the file upload. The setupRoutes
function defines the route /upload
and starts the server. The io
and os
libraries are used for reading the file and creating a new file respectively. The fmt
library is used for outputting messages to the console.
gistlibby LogSnag