Notice: Trying to access array offset on value of type null in /customers/1/2/4/mrwaggel.be/httpd.www/admin/kernel/db/db_posts.class.php on line 390 Notice: Trying to access array offset on value of type null in /customers/1/2/4/mrwaggel.be/httpd.www/admin/kernel/db/db_pages.class.php on line 337 Notice: Trying to access array offset on value of type null in /customers/1/2/4/mrwaggel.be/httpd.www/admin/kernel/db/db_comments.class.php on line 283 Deprecated: Function get_magic_quotes_runtime() is deprecated in /customers/1/2/4/mrwaggel.be/httpd.www/admin/boot/rules/4-remove_magic.bit on line 18 Deprecated: Function get_magic_quotes_gpc() is deprecated in /customers/1/2/4/mrwaggel.be/httpd.www/admin/boot/rules/4-remove_magic.bit on line 23 - fileMr.Waggel's blog

Golang serving resume able file downloads with net/http

30 March, 2020

Here is a fully commented example golang function on how to serve and transmit files to clients with the go net/http package. It supports the "Accept-Ranges" header, which allows for downloads to be paused or interrupted and resumed later on. This is very useful for clients who don't have stable connections to download larger files. However this function does not support Multipart downloads, if you wish to have that functionality check this function in the net/http source code for implementation.

This function is written with the following sources RFC 7233 section 3.1MDN Range Requests and Content Range.

Golang transmit files over a net/http server to clients

25 July, 2016

In this example I'll show you how to send a file from a net/http listener to a client. 

Update: resume functionality!

Check the updated version of this post.

Golang transfer a file over a TCP socket

21 May, 2016

In this tutorial I'll demonstrate how to send a file in Go over a TCP connection using a server that sends the file and a client that receives it, I'll try to go into detail as much as possible.

You can download the source code here.

Comments and remarks are more than welcome.

Generate SHA1 hash of a file in Golang example

08 April, 2016

This function is based on my previous post but adapted for the SHA1 algorithm.

Generate MD5 hash of a file in Golang

07 April, 2016

Why generate a MD5 hash of a file?

You may have noticed before on some websites where you download a file, there is some strange string of text around the download link, named "checksum", for example "md5 checksum: dcdfb1413d7fa48c3cab920c0448f236". Now this may look like a bunch of random characters to you but don't be fooled, it's a one-way mathematical hash that correspondents to the file you want to download.

Home