hugo
hugo copied to clipboard
Update to Go 1.18 (still in beta) (a list of Hugo related improvements)
The upcoming Go version (still some months away) is pretty cool, and contains some useful stuff for Hugo, too. I suspect we need to stop supporting older Go versions if we start using it, but that's probably worth it.
Some notes about what's new and relevant (also see https://tip.golang.org/doc/go1.18):
-
text/template
/html/template
- The
and
function no longer always evaluates all arguments; it stops evaluating arguments after the first argument that evaluates to false. Similarly, theor
function now stops evaluating arguments after the first argument that evaluates to true. This makes a difference if any of the arguments is a function call. -
break
andcontinue
for range
- The
- Generics (maybe not very relevant, but it may certainly simplify some internals)
- The go command now embeds version control information in binaries including the currently checked-out revision, commit time, and a flag indicating whether edited or untracked files are present.
- A new workspace mode (
go.work
) which should enable much improved local development of Hugo Modules. -
bytes
/strings
:- The new Cut function slices a []byte around a separator. It can replace and simplify many common uses of Index, IndexByte, IndexRune, and SplitN.
- Trim, TrimLeft, and TrimRight are now allocation free and, especially for small ASCII cutsets, up to 10 times faster.
- The Title function is now deprecated. It doesn't handle Unicode punctuation and language-specific capitalization rules, and is superseded by the golang.org/x/text/cases package.
-
reflect
- The new Value.SetIterKey and Value.SetIterValue methods set a Value using a map iterator as the source. They are equivalent to Value.Set(iter.Key()) and Value.Set(iter.Value()) but do fewer allocations.
- A number of methods ( Value.CanInt, Value.CanUint, Value.CanFloat, Value.CanComplex ) have been added to Value to test if a conversion is safe.
- ...
-
sync
- The new methods Mutex.TryLock, RWMutex.TryLock, and RWMutex.TryRLock, will acquire the lock if it is not currently held.
break
and continue
has been long awaited! As for the rest I trust your judgment ☺️.
Can the reflect
improvements let us hope for more type testing? (As in reflect.IsString
etc... ?
We updated to Go 1.18 with v0.95.0.
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.