# Using C Dynamic Libraries In Go Programs

DevFeed: [Using C Dynamic Libraries In Go Programs](<https://devfeed.tech/articles/using-c-dynamic-libraries-in-go-programs-22067.md>)

Original publisher: [Read original article](<https://www.ardanlabs.com/blog/2013/08/using-c-dynamic-libraries-in-go-programs.html>)

Published: 2013-08-20T00:00:00Z

Content type: tutorial

Language: en

Sources: [William Kennedy](<https://devfeed.tech/sources/william-kennedy.md>)

Topics: [Go Language](<https://devfeed.tech/topics/go-language.md>), [C](<https://devfeed.tech/topics/c.md>), [Programming](<https://devfeed.tech/topics/programming.md>), [gcc](<https://devfeed.tech/topics/gcc.md>), [make](<https://devfeed.tech/topics/make.md>)

Tags: [ardan-labs](<https://devfeed.tech/tags/ardan-labs.md>), [blog](<https://devfeed.tech/tags/blog.md>), [c](<https://devfeed.tech/tags/c.md>), [coding](<https://devfeed.tech/tags/coding.md>), [gcc](<https://devfeed.tech/tags/gcc.md>), [go](<https://devfeed.tech/tags/go.md>), [go-programming](<https://devfeed.tech/tags/go-programming.md>), [golang](<https://devfeed.tech/tags/golang.md>), [make](<https://devfeed.tech/tags/make.md>), [ncurses](<https://devfeed.tech/tags/ncurses.md>), [programming](<https://devfeed.tech/tags/programming.md>)

## AI overview

This tutorial describes building terminal keyboard-input functionality in C with the ncurses dynamic library and linking that functionality to a Go program. It includes C source code and a Makefile using gcc, though the supplied excerpt ends during the build instructions.

## Source excerpt

My son and I were having fun last weekend building a console based game in Go. I was recreating a game from my youth, back when I was programming on a Kaypro II. View linked image: kayproii I loved this computer. I would write games in BASIC on it all day and night. Did I mention it was portable. The keyboard would strap in and you could carry it around. LOL. But I digress, back to my Go program. I figured out a way to use the VT100 escape character codes to draw out a simple screen and started programming some of the logic. Then something horrible happened and I had a major flashback. I could not get input from stdin without hitting the enter key. Ahhhhh I spent all weekend reading up on how to make this happen. I even found two Go libraries that had support for this but they didn't work. I realized that if I was going to make this happen I needed to build the functionality in C and link that to my Go program. After a 4 hour coding session at the local Irish pub, I figured it out. I would like to thank Guinness for the inspiration and encouragement I needed. Understand that for the past 10 years I have been writing windows services in C#. For 10 years before that I was writing C/C++ but on the Microsoft stack. Everything I was reading: gcc, gco, static and shared libraries on the Mac and Linux, etc, was foreign to me. I had a lot to learn and still do. After all my research it became clear I needed to use the ncurses dynamic library. I decided to write a simple program in C using the library. If I could make it work in a compiled C program, I was sure I could get it to work in Go. View linked image: Screen Shot