If you're a technical person and you don't like to battle with presentation softwares but you want/need to create one, congratulations! you are in the right place. I know that as software engineers we want to be coding or reading or watching things related with software, architecture or devops but not with presentations. Sometimes we are demanded to present something to other team members, to the product owners or even scarier, to the management team!
For that reason I want to introduce you to the Go package present. It's used to create slides in Golang hosted on talks.golang.org or on your private one. I've used it several times, especially when I want to share something to my colleagues on the team (some code of course), because I don't want to waste time with softwares. I just create the project for the slides, add my slides in markdown, add the images needed and just present them to them. Let's see in detail how it works!
Assuming you have Go installed and correctly configured, all you need to install is the package with the following command:
go get -u golang.org/x/tools/present
Test if it works typing:
present
And it should display a message similar to:
2020/10/04 23:23:54 Open your web browser and visit http://127.0.0.1:3999
So you can visit the link, and see the local server ready to host your presentations. Awesome or not? Okay, I know you want to display something other than an empty directory, so let's create an example presentation for that.
Format
Create a directory for your slides:
mkdir go-present-example
cd go-present-example/
Create your first slide:
vim initial.slide
And add the following:
Learning Go present
6 October 2020
Crash Bandicoot
crash.bandicoot@gmail.com
* Hello World
I'm a slide
So if you run again the present
command inside your folder and go to the browser again you should be able to see the screen below:
Click on the initial.slide
link and admire your presentation!
As you can see, the first line is the title, the second the date and then it's followed by the author. On the second slide, actually the first one, it appears the title of the slide and the text of that one. The last one displays a gratitude title and your name and contact (email, twitter, etc.) you added in the slide. See it below:
Legacy Present Syntax
It supports Markdown but here we will explore the Legacy Present Syntax, as the Markdown has a lot of resources where you can check. So let's explore a bit the features that present
offers for formatting and displaying text in our slides.
First is the classical options for formatting the text:
normal vs `highlighted`
*bold*
_italic_
*multiple*bold*text*
_multiple_italic_text_
Also you can add a list:
Grocery list for the gopher:
- go routines
- garbage collector
- Rust
Or different level of subsections like that:
** Subsection
Gopher is diving the subsection.
*** Sub-subsection
Another Gopher is diving more into the sub-subsection!
And you will see the slide like this craziness:
Command Invocations
Apart from text formatting there are a special command invocations that you can invoke to take your presentation to another level.
images & videos
The .image
command injects a picture in your slide. It accepts 1 or 3 arguments (name, height, width). Name is mandatory, other two must be present or substituted with an _
.
.image /images/gopher.jpeg 200 200
.image /images/gopher.jpeg _ 300
Like the pictures, you can do the same with a video using the .video
command. It accepts 2 or 4 arguments (name, file content-type, height, width). Name and file content-type are mandatories, other two must be present or substituted with and _
.
.video videos/gopher-dance.mp4 video/mp4 400 600
.video videos/gopher-dance.mkv video/mkv 500 _
Similar to the images, it also has the .background
command to set the background image for a slide. It has only one argument as the file name of the image.
.background images/susan.jpg
links
If you need to insert a link in your presentation you can use the .link
command. It accepts 1 or 2 arguments (HTTP url, text label). HTTP url is mandatory, the second one is optional.
.link https://charly3pins.dev charly3pins website
.link https://charly3pins.dev
code
The best command imo is the .code
one. It allows you to put code extracting them from the source files and injecting them as HTML-escaped pre blocks. It accepts one argument as the file name followed by an optional address that specifies what section of the file to display.
For example taking the Hello world in Go as a source code:
package main
import "fmt"
func main() {
fmt.Println("Hello world!")
}
We need to specify as:
.code hello.go
But what happens if you want to highlight some part of the code? Don't worry, present has that "present" and you can add those "optional addresses" we commented below for that. So, modify the code like that to highlight the Printf
call:
package main
import "fmt"
func main() {
fmt.Println("Hello world!") // HL
}
And use the same command in your slide:
.code hello-hl.go
One step further! If you wanna show only a part of your code, for example hide the package and the imports of your file, you can also add the following snippets:
package main
import "fmt"
//START OMIT
func main() {
fmt.Println("Hello world!") // HL
}
//END OMIT
Again use the same command but adding the following snippet:
.code hello-hl-partial.go /START OMIT/,/END OMIT/
And see the code partially displayed:
play
That command is superpowerful in order to help you present some code and highlight or hide some parts. But the show must go on, and the best part is the next one. The command .play
is like the code
one but it puts a button on the dispalyed source and you can run your program from the browser! Is it magic or not?
So let's use the same source-code that we are using and just add the new command to the slides like this:
.play hello.go
It will appear like the code
one but if you notice on the right bottom corner, it appears a small Run
button.
Running the code will display a small black window on the screen displaying the output of the code:
Presenter Notes
Last but not least is an interesting thing that they provide also. It's well known that in PowerPoint or similar programs you can add your notes only visible for you when presenting the presentation and they are very useful sometimes. So present
has that in consideration as well and you can add your presentation notes just adding a :
on the beginning of the sentence and that text will be treated as a presenter note.
For example:
* Presenter notes
The gophers like to eat a lot.
: they eat more than half their body weight in food each day
They eat basically plants.
: typically gnaws the roots of a plant just beneath the soil, so the damage isn’t seen
As you can see the notes aren't present there, so WHY? Because you need to run the presentation in a "presenter" like that.
present -notes
And it should display a message similar to:
2020/10/04 23:23:54 Open your web browser and visit http://127.0.0.1:3999
2020/10/04 Notes are enabled, press 'N' from the browser to display them.
So if you refresh your browser with the presentation and press N
you will see a popup displaying the notes of each slide on the bottom like that:
Conclusion
The present
tool is super useful for technical presentations, especially in Go. It has its limitations like the format of the slides and the image positioning sometimes tricky, but in general is a great package and for me is the standard for all my presentations. If you wanna dick more in detail about that package check the official documentation and also I would recommend the presentation: Inside the "present" tool
by Andrew Gerrand. Also I've uploaded the source code for this tutorial on GitHub.
I hope it helps you and feel free to comment here or contact me on my social media for any comments, questions or suggestions.
Top comments (0)