Go packages in TypeScript
TypeScript implementations of 87 Go standard library functions across 9 modules. Each function is individually importable and tree-shakeable.
filepath net path sort strconv strings- Compare
- Contains
- ContainsAny
- Count
- Cut
- CutPrefix
- CutSuffix
- EqualFold
- Fields
- HasPrefix
- HasSuffix
- Index
- IndexAny
- Join
- LastIndex
- LastIndexAny
- Repeat
- Replace
- ReplaceAll
- Split
- SplitN
- ToLower
- ToUpper
- Trim
- TrimLeft
- TrimPrefix
- TrimRight
- TrimSpace
- TrimSuffix
- Add
- AddDate
- After
- Before
- Date
- Equal
- Format
- Parse
- ParseDuration
- ParseInLocation
- Round
- Sub
- Truncate
- Unix
- UnixMicro
- UnixMilli
Help us add more
Got a rainy Sunday afternoon and a taste for a porting puzzle?
- Get inspiration from Go strings documentation, Go strings source, Go strings examples source, GopherJS.
- Click "New file" in the appropriate folder on GitHub. This will fork the project to your account, directly add the file to it, and send a Pull Request to us.
We will then review it. If it's useful to the project and in line with our contributing guidelines your work will become part of Locutus and you'll be automatically credited in the authors section accordingly.
Upstream Surface Inventory 87/557 shipped · 229 next 16%
Locutus tracks 19 upstream namespaces for Go and sorts them into what is already shipped, what we still want, what we intentionally keep, and what still needs a decision.
This inventory now tracks a broader official Go stdlib slice, using `go doc` runtime/source discovery for packages whose exported function surface is stable and value-oriented.
In progress
Next
Go path helpers are strong plain string portability targets.
Split
Next
Constant-time scalar comparison helpers fit plain-value portability well.
ConstantTimeByteEqConstantTimeLessOrEq
Explicit non-goals (1)
-
XORBytesMutable byte-buffer APIs do not fit Locutus' current plain-value model.
Shipped (29)
Next
Go strings helpers are core portability targets for Locutus.
ContainsFuncContainsRuneFieldsFuncIndexByteIndexFuncIndexRuneLastIndexByteLastIndexFuncMapSplitAfterSplitAfterNTitleToLowerSpecialToTitleToTitleSpecialToUpperSpecialToValidUTF8TrimFuncTrimLeftFuncTrimRightFunc
Explicit non-goals (3)
-
CloneA string clone helper adds little value in JavaScript. -
NewReaderReader objects are not a stable plain-value target. -
NewReplacerReplacer objects are not a stable plain-value target.
Next
Filepath helpers are high-value plain string portability targets.
FromSlashIsLocalMatchSplitSplitListToSlashVolumeName
Explicit non-goals (7)
-
AbsAbsolute-path resolution depends on process working-directory state. -
EvalSymlinksSymlink resolution depends on filesystem state. -
GlobFilesystem globbing depends on host state. -
HasPrefixDeprecated path-prefix checks add little value to the roadmap. -
LocalizeOS-specific path localization depends on host path semantics. -
WalkFilesystem traversal depends on host state and callback side effects. -
WalkDirFilesystem traversal depends on host state and callback side effects.
Shipped (10)
Next
Parse and format helpers are strong plain-value portability targets.
CanBackquoteFormatUintIsGraphicIsPrintParseUintQuotedPrefixQuoteRuneQuoteRuneToASCIIQuoteRuneToGraphicQuoteToASCIIQuoteToGraphicUnquoteChar
Explicit non-goals (12)
-
AppendBoolByte-slice append APIs do not fit Locutus' current plain-value model. -
AppendFloatByte-slice append APIs do not fit Locutus' current plain-value model. -
AppendIntByte-slice append APIs do not fit Locutus' current plain-value model. -
AppendQuoteByte-slice append APIs do not fit Locutus' current plain-value model. -
AppendQuoteRuneByte-slice append APIs do not fit Locutus' current plain-value model. -
AppendQuoteRuneToASCIIByte-slice append APIs do not fit Locutus' current plain-value model. -
AppendQuoteRuneToGraphicByte-slice append APIs do not fit Locutus' current plain-value model. -
AppendQuoteToASCIIByte-slice append APIs do not fit Locutus' current plain-value model. -
AppendQuoteToGraphicByte-slice append APIs do not fit Locutus' current plain-value model. -
AppendUintByte-slice append APIs do not fit Locutus' current plain-value model. -
FormatComplexComplex-number formatting does not fit JS plain values. -
ParseComplexComplex-number parsing does not fit JS plain values.
Shipped (8)
Next
Escaping helpers have a clean plain-value contract.
EscapedFragmentEscapedPath
URL host decomposition is a useful plain-value helper.
HostnamePort
URL absolute checks have a clean plain-value contract.
IsAbs
Request-URI parsing is a useful plain-value helper.
ParseRequestURI
URL escaping is a strong plain-value target.
PathUnescape
Request-URI formatting is a useful plain-value helper.
RequestURI
Explicit non-goals (12)
-
AddMuch of net/url revolves around mutable URL and Values objects rather than plain values. -
DelMuch of net/url revolves around mutable URL and Values objects rather than plain values. -
GetMuch of net/url revolves around mutable URL and Values objects rather than plain values. -
HasMuch of net/url revolves around mutable URL and Values objects rather than plain values. -
MarshalBinaryMuch of net/url revolves around mutable URL and Values objects rather than plain values. -
QueryMuch of net/url revolves around mutable URL and Values objects rather than plain values. -
RedactedMuch of net/url revolves around mutable URL and Values objects rather than plain values. -
SetMuch of net/url revolves around mutable URL and Values objects rather than plain values. -
StringMuch of net/url revolves around mutable URL and Values objects rather than plain values. -
UnmarshalBinaryMuch of net/url revolves around mutable URL and Values objects rather than plain values. -
UserMuch of net/url revolves around mutable URL and Values objects rather than plain values. -
UserPasswordMuch of net/url revolves around mutable URL and Values objects rather than plain values.
Shipped (16)
Next
Time comparison has a clean plain-value contract.
Compare
Unix timestamp conversion has a clean plain-value contract.
UnixNano
Explicit non-goals (41)
-
AfterFuncTimer callbacks are side-effectful runtime scheduling APIs. -
AppendFormatMuch of Go time depends on locations, timers, and rich time values beyond JS plain values. -
ClockMuch of Go time depends on locations, timers, and rich time values beyond JS plain values. -
DayMuch of Go time depends on locations, timers, and rich time values beyond JS plain values. -
FixedZoneMuch of Go time depends on locations, timers, and rich time values beyond JS plain values. -
GobDecodeMuch of Go time depends on locations, timers, and rich time values beyond JS plain values. -
GobEncodeMuch of Go time depends on locations, timers, and rich time values beyond JS plain values. -
GoStringMuch of Go time depends on locations, timers, and rich time values beyond JS plain values. -
HourMuch of Go time depends on locations, timers, and rich time values beyond JS plain values. -
InMuch of Go time depends on locations, timers, and rich time values beyond JS plain values. -
IsDSTMuch of Go time depends on locations, timers, and rich time values beyond JS plain values. -
ISOWeekMuch of Go time depends on locations, timers, and rich time values beyond JS plain values. -
IsZeroMuch of Go time depends on locations, timers, and rich time values beyond JS plain values. -
LoadLocationTimezone database loading depends on host runtime state. -
LoadLocationFromTZDataTimezone database loading depends on host runtime state. -
LocalMuch of Go time depends on locations, timers, and rich time values beyond JS plain values. -
LocationMuch of Go time depends on locations, timers, and rich time values beyond JS plain values. -
MarshalBinaryMuch of Go time depends on locations, timers, and rich time values beyond JS plain values. -
MarshalJSONMuch of Go time depends on locations, timers, and rich time values beyond JS plain values. -
MarshalTextMuch of Go time depends on locations, timers, and rich time values beyond JS plain values. -
MinuteMuch of Go time depends on locations, timers, and rich time values beyond JS plain values. -
MonthMuch of Go time depends on locations, timers, and rich time values beyond JS plain values. -
NanosecondMuch of Go time depends on locations, timers, and rich time values beyond JS plain values. -
NewTickerMuch of Go time depends on locations, timers, and rich time values beyond JS plain values. -
NewTimerMuch of Go time depends on locations, timers, and rich time values beyond JS plain values. -
NowMuch of Go time depends on locations, timers, and rich time values beyond JS plain values. -
SecondMuch of Go time depends on locations, timers, and rich time values beyond JS plain values. -
SinceMuch of Go time depends on locations, timers, and rich time values beyond JS plain values. -
SleepMuch of Go time depends on locations, timers, and rich time values beyond JS plain values. -
StringMuch of Go time depends on locations, timers, and rich time values beyond JS plain values. -
TickMuch of Go time depends on locations, timers, and rich time values beyond JS plain values. -
UnmarshalBinaryMuch of Go time depends on locations, timers, and rich time values beyond JS plain values. -
UnmarshalJSONMuch of Go time depends on locations, timers, and rich time values beyond JS plain values. -
UnmarshalTextMuch of Go time depends on locations, timers, and rich time values beyond JS plain values. -
UntilMuch of Go time depends on locations, timers, and rich time values beyond JS plain values. -
UTCMuch of Go time depends on locations, timers, and rich time values beyond JS plain values. -
WeekdayMuch of Go time depends on locations, timers, and rich time values beyond JS plain values. -
YearMuch of Go time depends on locations, timers, and rich time values beyond JS plain values. -
YearDayMuch of Go time depends on locations, timers, and rich time values beyond JS plain values. -
ZoneMuch of Go time depends on locations, timers, and rich time values beyond JS plain values. -
ZoneBoundsMuch of Go time depends on locations, timers, and rich time values beyond JS plain values.
Shipped (2)
Next
Index search helpers are useful plain-value targets.
Find
Search helpers have a clean plain-value contract.
SearchSearchFloat64sSearchInts
Explicit non-goals (12)
-
Float64sMost sort APIs depend on mutable slices or callback-driven ordering. -
Float64sAreSortedMost sort APIs depend on mutable slices or callback-driven ordering. -
IntsMost sort APIs depend on mutable slices or callback-driven ordering. -
IntsAreSortedMost sort APIs depend on mutable slices or callback-driven ordering. -
IsSortedMost sort APIs depend on mutable slices or callback-driven ordering. -
ReverseMost sort APIs depend on mutable slices or callback-driven ordering. -
SliceMost sort APIs depend on mutable slices or callback-driven ordering. -
SliceIsSortedMost sort APIs depend on mutable slices or callback-driven ordering. -
SliceStableMost sort APIs depend on mutable slices or callback-driven ordering. -
SortMost sort APIs depend on mutable slices or callback-driven ordering. -
StableMost sort APIs depend on mutable slices or callback-driven ordering. -
StringsMost sort APIs depend on mutable slices or callback-driven ordering.
Shipped (4)
Next
IP mask construction has a clean plain-value contract.
CIDRMaskIPv4Mask
IPv4 construction has a clean plain-value contract.
IPv4
MAC parsing has a clean plain-value contract.
ParseMAC
Explicit non-goals (37)
-
DialMost net helpers depend on sockets, DNS, or host network state. -
DialIPMost net helpers depend on sockets, DNS, or host network state. -
DialTCPMost net helpers depend on sockets, DNS, or host network state. -
DialTimeoutMost net helpers depend on sockets, DNS, or host network state. -
DialUDPMost net helpers depend on sockets, DNS, or host network state. -
DialUnixMost net helpers depend on sockets, DNS, or host network state. -
FileConnMost net helpers depend on sockets, DNS, or host network state. -
FileListenerMost net helpers depend on sockets, DNS, or host network state. -
FilePacketConnMost net helpers depend on sockets, DNS, or host network state. -
InterfaceAddrsMost net helpers depend on sockets, DNS, or host network state. -
InterfaceByIndexMost net helpers depend on sockets, DNS, or host network state. -
InterfaceByNameMost net helpers depend on sockets, DNS, or host network state. -
InterfacesMost net helpers depend on sockets, DNS, or host network state. -
ListenMost net helpers depend on sockets, DNS, or host network state. -
ListenIPMost net helpers depend on sockets, DNS, or host network state. -
ListenMulticastUDPMost net helpers depend on sockets, DNS, or host network state. -
ListenPacketMost net helpers depend on sockets, DNS, or host network state. -
ListenTCPMost net helpers depend on sockets, DNS, or host network state. -
ListenUDPMost net helpers depend on sockets, DNS, or host network state. -
ListenUnixMost net helpers depend on sockets, DNS, or host network state. -
ListenUnixgramMost net helpers depend on sockets, DNS, or host network state. -
LookupAddrMost net helpers depend on sockets, DNS, or host network state. -
LookupCNAMEMost net helpers depend on sockets, DNS, or host network state. -
LookupHostMost net helpers depend on sockets, DNS, or host network state. -
LookupIPMost net helpers depend on sockets, DNS, or host network state. -
LookupMXMost net helpers depend on sockets, DNS, or host network state. -
LookupNSMost net helpers depend on sockets, DNS, or host network state. -
LookupPortMost net helpers depend on sockets, DNS, or host network state. -
LookupSRVMost net helpers depend on sockets, DNS, or host network state. -
LookupTXTMost net helpers depend on sockets, DNS, or host network state. -
PipeMost net helpers depend on sockets, DNS, or host network state. -
ResolveIPAddrMost net helpers depend on sockets, DNS, or host network state. -
ResolveTCPAddrMost net helpers depend on sockets, DNS, or host network state. -
ResolveUDPAddrMost net helpers depend on sockets, DNS, or host network state. -
ResolveUnixAddrMost net helpers depend on sockets, DNS, or host network state. -
TCPAddrFromAddrPortMost net helpers depend on sockets, DNS, or host network state. -
UDPAddrFromAddrPortMost net helpers depend on sockets, DNS, or host network state.
math package
Next
Scalar math helpers are strong Go portability targets.
AbsAcosAcoshAsinAsinhAtanAtan2AtanhCbrtCeilCopysignCosCoshDimErfErfcErfcinvErfinvExpExp2Expm1Float32bitsFloat32frombitsFloat64bitsFloat64frombitsFloorFMAFrexpGammaHypotIlogbInfIsInfIsNaNJ0J1JnLdexpLgammaLogLog10Log1pLog2LogbMaxMinModModfNaNNextafterNextafter32PowPow10RemainderRoundRoundToEvenSignbitSinSincosSinhSqrtTanTanhTruncY0Y1Yn
math/bits package
Next
Bit-twiddling helpers over integers are strong scalar portability targets.
AddAdd32Add64DivDiv32Div64LeadingZerosLeadingZeros16LeadingZeros32LeadingZeros64LeadingZeros8LenLen16Len32Len64Len8MulMul32Mul64OnesCountOnesCount16OnesCount32OnesCount64OnesCount8RemRem32Rem64ReverseReverse16Reverse32Reverse64Reverse8ReverseBytesReverseBytes16ReverseBytes32ReverseBytes64RotateLeftRotateLeft16RotateLeft32RotateLeft64RotateLeft8SubSub32Sub64TrailingZerosTrailingZeros16TrailingZeros32TrailingZeros64TrailingZeros8
slices package
Next
Pure slice transforms and search helpers are strong portability targets when they do not mutate caller-owned state.
AllAppendSeqBackwardBinarySearchCollect
Slice chunking has a clean plain-value contract.
Chunk
Adjacent de-duplication has a clean plain-value contract.
Compact
Lexicographic slice comparison has a clean plain-value contract.
Compare
Slice concatenation maps naturally onto JS arrays.
Concat
Membership checks have a clean plain-value contract.
Contains
Non-mutating delete semantics can be modeled as array slicing.
Delete
Slice equality has a clean plain-value contract.
Equal
Membership search has a clean plain-value contract.
Index
Pure slice insertion has a clean plain-value contract.
Insert
Order checks have a clean plain-value contract.
IsSorted
Aggregate scalar helpers have a clean plain-value contract.
MaxMin
Slice repetition maps naturally onto array repetition.
Repeat
Pure slice replacement has a clean plain-value contract.
Replace
Reversal has a clean plain-value contract.
Reverse
Deterministic slice sorting is a strong portability target.
Sort
Explicit non-goals (19)
-
BinarySearchFuncComparator-callback variants add more runtime-shape complexity than value. -
ClipCapacity trimming does not matter in JS array semantics. -
CloneCloning alone adds little value for JS arrays. -
CompactFuncComparator-callback variants add more runtime-shape complexity than value. -
CompareFuncComparator-callback variants add more runtime-shape complexity than value. -
ContainsFuncPredicate-callback variants add more runtime-shape complexity than value. -
DeleteFuncPredicate-callback deletion adds more runtime-shape complexity than value. -
EqualFuncComparator-callback variants add more runtime-shape complexity than value. -
GrowCapacity growth does not matter in JS array semantics. -
IndexFuncPredicate-callback variants add more runtime-shape complexity than value. -
IsSortedFuncComparator-callback variants add more runtime-shape complexity than value. -
MaxFuncComparator-callback variants add more runtime-shape complexity than value. -
MinFuncComparator-callback variants add more runtime-shape complexity than value. -
SortedIterator-oriented collection helpers do not map cleanly to Locutus today. -
SortedFuncIterator-oriented collection helpers do not map cleanly to Locutus today. -
SortedStableFuncIterator-oriented collection helpers do not map cleanly to Locutus today. -
SortFuncComparator-callback variants add more runtime-shape complexity than value. -
SortStableFuncComparator-callback variants add more runtime-shape complexity than value. -
ValuesIterator-oriented collection helpers do not map cleanly to Locutus today.
unicode package
Next
Character classification helpers have a clean scalar portability contract.
IsIsControlIsDigitIsGraphicIsLetterIsLowerIsMarkIsNumberIsOneOfIsPrintIsPunctIsSpaceIsSymbolIsTitleIsUpper
Codepoint folding has a clean scalar portability contract.
SimpleFold
Codepoint case conversion has a clean scalar portability contract.
ToLowerToTitleToUpper
unicode/utf8 package
Next
String-oriented rune decoding has a clean plain-value contract.
DecodeLastRuneInStringDecodeRuneInString
String-oriented UTF-8 validity checks have a clean plain-value contract.
FullRuneInStringValidString
String-oriented UTF-8 counting has a clean plain-value contract.
RuneCountInString
Rune-size helpers have a clean scalar portability contract.
RuneLen
Rune-validity checks have a clean scalar portability contract.
ValidRune
Explicit non-goals (8)
-
AppendRuneMany utf8 helpers operate on byte slices rather than plain JS values. -
DecodeLastRuneMany utf8 helpers operate on byte slices rather than plain JS values. -
DecodeRuneMany utf8 helpers operate on byte slices rather than plain JS values. -
EncodeRuneMany utf8 helpers operate on byte slices rather than plain JS values. -
FullRuneMany utf8 helpers operate on byte slices rather than plain JS values. -
RuneCountMany utf8 helpers operate on byte slices rather than plain JS values. -
RuneStartMany utf8 helpers operate on byte slices rather than plain JS values. -
ValidMany utf8 helpers operate on byte slices rather than plain JS values.
cmp package
Next
Generic comparison helpers over plain values are strong portability targets.
CompareLessOr
maps package
Next
Plain map cloning maps naturally onto JS object copying.
Clone
Plain map equality has a clean portability contract.
Equal
Explicit non-goals (8)
-
AllParts of maps revolve around iterators or callback-driven equality rather than one stable plain-value contract. -
CollectParts of maps revolve around iterators or callback-driven equality rather than one stable plain-value contract. -
CopyParts of maps revolve around iterators or callback-driven equality rather than one stable plain-value contract. -
DeleteFuncParts of maps revolve around iterators or callback-driven equality rather than one stable plain-value contract. -
EqualFuncParts of maps revolve around iterators or callback-driven equality rather than one stable plain-value contract. -
InsertParts of maps revolve around iterators or callback-driven equality rather than one stable plain-value contract. -
KeysParts of maps revolve around iterators or callback-driven equality rather than one stable plain-value contract. -
ValuesParts of maps revolve around iterators or callback-driven equality rather than one stable plain-value contract.
encoding/hex package
Next
Encoded-length helpers have a clean plain-value contract.
EncodedLen
Explicit non-goals (11)
-
AppendDecodeByte-slice oriented hex helpers do not fit Locutus' current plain-value model by default. -
AppendEncodeByte-slice oriented hex helpers do not fit Locutus' current plain-value model by default. -
DecodeByte-slice oriented hex helpers do not fit Locutus' current plain-value model by default. -
DecodedLenByte-slice oriented hex helpers do not fit Locutus' current plain-value model by default. -
DecodeStringByte-slice oriented hex helpers do not fit Locutus' current plain-value model by default. -
DumpByte-slice oriented hex helpers do not fit Locutus' current plain-value model by default. -
DumperByte-slice oriented hex helpers do not fit Locutus' current plain-value model by default. -
EncodeByte-slice oriented hex helpers do not fit Locutus' current plain-value model by default. -
EncodeToStringByte-slice oriented hex helpers do not fit Locutus' current plain-value model by default. -
NewDecoderByte-slice oriented hex helpers do not fit Locutus' current plain-value model by default. -
NewEncoderByte-slice oriented hex helpers do not fit Locutus' current plain-value model by default.