Skip to content

go experiment to test if string is one of a set of constants

Notifications You must be signed in to change notification settings

ericjster/go_test_string_const

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

try-string-const

This project tries to find a way to determine if a string is a const, in an efficient way.

The simple idea is to create a long string which is a concatenation of all strings. Then we create the individual strings from it.

In practice we would want to use go generate to create the separate strings, very similar to stringer. See this blog post by Rob Pike for details on go generate and stringer: https://blog.golang.org/generate

Then to determine if a string is a const, we check if the memory for the string is inside a larger string. We expect that can be done in a few machine instructions.

About

go experiment to test if string is one of a set of constants

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages