Estimated Reading Time: 5 minutes


作者按:假期中闲来无事,想把 Golang 学习一下。

趁着疫情导致的“加长版”假期,编写了一个自己的 Pastebin 服务,对标 ptpb/pb 这套服务(公开实例: ),之前自己也架设过一套这类服务,这套服务易用,但是没有任何的清理和防滥用机制,Python 编写也导致性能奇差。而我是一个注重隐私和安全的人,希望能够自己掌控自己的数据,同时向公众提供高效可靠的服务。

我曾经还架设过 fiche (公开实例: ),这个用 c 编写的纯 Socket Pastebin,虽然好用,但是没有办法抵挡住任何的 Bot,且会产生大量的磁盘碎片。也没有代码高亮功能。

Golang 编写的程序具有原生交叉编译和单二进制文件的特性,同时也兼具了编译语言相对解释语言的高效,同时门槛较低。在实现这个产品的过程中,得到了 STRRL 的支持,非常感谢。这个产品的实践也让我加深了对 OOP 的理解和软件工程设计、流程、项目协作的了解,也踩了一些新手容易踩的 Golang 的坑,积累了一定的经验。


  • Abuse detection, we do allow pure text only, no photos, no binaries, the uploaded file size can only be less than 2 megabytes.
  • ReCAPTCHA support. If you do experiencing a lot from bot, you could try my product.
  • Client Tool. We build a powerful client cli tools for you to use, you could also use the curl, there’s no difference. This tool even allow administrator to delete some illegal snippet quickly. If you wanna use it for private sharing, we could help you generate a random 6-digit password for access, you could also define it by yourself.
  • Data encryption on storage. We do use chacha20-poly1305 to save your snippet. Due to the need of abuse detection, we can’t and we won’t implement any client-side encryption.
  • Original Shortlink support. We only support shortlink, for convenience.
  • Auto expiring. Previously, ptpb/pb need administrator to clear the database manually. We do force an expiring time for all uploaded data. The maximum allowed expiration of program is 24h, you can define it yourself, but cannot larger than 24. As for MongoDB, it won’t release the disk space it allocated even the documents deleted, you could try "compact" database if you want.
  • Burn-after-read support. Optionally defined by an end user, we allow it. But the server default expiration cannot be 0.
  • Syntax highlighting by default, using Google’s prettify.js, same version as . If you need raw paste, simply add f=raw as url param in request.
  • No extra cost. We don’t wanna show anything towards illegal/invalid request. You just get a status code without any html page sent by our server.
  • Web page upload.
  • Single binary. We don’t need any other dependencies except MongoDB.




如果您喜欢的话,不妨给我个 Star,谢谢。我们也欢迎您在使用过程中对我们的项目提出宝贵的意见和建议。项目 Readme 页面有我们的交流群地址,项目 Issue 也同时为您开放。