Hana 9e216da9ef go.mod: add go.mod and move pygments to third_party
After go1.16, go will use module mode by default,
even when the repository is checked out under GOPATH
or in a one-off directory. Add go.mod, go.sum to keep
this repo buildable without opting out of the module
mode.

> go mod init github.com/mmcgrana/gobyexample
> go mod tidy
> go mod vendor

In module mode, the 'vendor' directory is special
and its contents will be actively maintained by the
go command. pygments aren't the dependency the go will
know about, so it will delete the contents from vendor
directory. Move it to `third_party` directory now.

And, vendor the blackfriday package.

Note: the tutorial contents are not affected by the
change in go1.16 because all the examples in this
tutorial ask users to run the go command with the
explicit list of files to be compiled (e.g.
`go run hello-world.go` or `go build command-line-arguments.go`).
When the source list is provided, the go command does
not have to compute the build list and whether it's
running in GOPATH mode or module mode becomes irrelevant.
2021-02-15 16:45:26 -05:00

75 lines
2.1 KiB
Plaintext

xquery version "3.0";
declare function local:add-log-message($message as xs:string) as empty-sequence()?
{
let $logfile-collection := "/db/apps/exist101/log"
let $logfile-name := "exist101-log.xml"
let $logfile-full := concat($logfile-collection, '/', $logfile-name)
let $logfile-created :=
if(doc-available($logfile-full))then
$logfile-full
else
xmldb:store($logfile-collection, $logfile-name, <eXist101-Log/>)
return
update insert
<LogEntry timestamp="{current-dateTime()}">{$message}</LogEntry>
into doc($logfile-full)/*
};
declare function local:insert-attributes() {
let $elm as element() := doc('/db/Path/To/Some/Document.xml')/*
return (
update insert <NEW/> into $elm,
update insert attribute x { 'y' } into $elm/*[last()],
update insert attribute a { 'b' } into $elm/*[last()]
)
};
declare function local:insert-elem() {
let $elm as element() := doc('/db/Path/To/Some/Document.xml')/*
return
update insert <NEW x="y" a="b"/> into $elm
};
declare function local:insert-elem2() {
let $elm as element() := doc('/db/Path/To/Some/Document.xml')/*
let $new-element as element() := <NEW x="y" a="b"/>
return
update insert $new-element into $elm
};
declare function local:insert-single() {
update insert <LogEntry>Something happened...</LogEntry> into doc('/db/logs/mainlog.xml')/*
};
declare function local:trim-insert() {
let $document := doc('/db/logs/mainlog.xml')
let $newentry := <LogEntry>Something happened...</LogEntry>
return
update delete $document/*/LogEntry[position() ge 10],
if(exists($document/*/LogEntry[1]))then
update insert $newentry preceding $document/*/LogEntry[1]
else
update insert $newentry into $document/*
};
declare function local:attempt-document-node-insert() {
(: This is invalid: :)
let $document as document-node() := <Root><a/></Root>
return
update insert <b/> into $document/*
};
declare function local:attempt-attr-update-with-node() {
update replace doc('/db/test/test.xml')/*/@name with
<a>aaa<b>bbb</b></a>
};
(# exist:batch-transaction #) {
update delete $document/*/LogEntry[position() ge 10],
update insert $newentry preceding $document/*/LogEntry[1]
}