Package qml offers graphical QML application support for the Go language. This package is in an alpha stage, and still in heavy development. APIs may change, and things may break. At this time contributors and developers that are interested in tracking the development closely are encouraged to use it. If you'd prefer a more stable release, please hold on a bit and subscribe to the mailing list for news. It's in a pretty good state, so it shall not take too long. See http://github.com/go-qml/qml for details. The qml package enables Go programs to display and manipulate graphical content using Qt's QML framework. QML uses a declarative language to express structure and style, and supports JavaScript for in-place manipulation of the described content. When using the Go qml package, such QML content can also interact with Go values, making use of its exported fields and methods, and even explicitly creating new instances of registered Go types. A simple Go application that integrates with QML may perform the following steps for offering a graphical interface: Some of these topics are covered below, and may also be observed in practice in the following examples: The following logic demonstrates loading a QML file into a window: Any QML object may be manipulated by Go via the Object interface. That interface is implemented both by dynamic QML values obtained from a running engine, and by Go types in the qml package that represent QML values, such as Window, Context, and Engine. For example, the following logic creates a window and prints its width whenever it's made visible: Information about the methods, properties, and signals that are available for QML objects may be obtained in the Qt documentation. As a reference, the "visibleChanged" signal and the "width" property used in the example above are described at: When in doubt about what type is being manipulated, the Object.TypeName method provides the type name of the underlying value. The simplest way of making a Go value available to QML code is setting it as a variable of the engine's root context, as in: This logic would enable the following QML code to successfully run: While registering an individual Go value as described above is a quick way to get started, it is also fairly limited. For more flexibility, a Go type may be registered so that QML code can natively create new instances in an arbitrary position of the structure. This may be achieved via the RegisterType function, as the following example demonstrates: With this logic in place, QML code can create new instances of Person by itself: Independently from the mechanism used to publish a Go value to QML code, its methods and fields are available to QML logic as methods and properties of the respective QML object representing it. As required by QML, though, the Go method and field names are lowercased according to the following scheme when being accesed from QML: While QML code can directly read and write exported fields of Go values, as described above, a Go type can also intercept writes to specific fields by declaring a setter method according to common Go conventions. This is often useful for updating the internal state or the visible content of a Go-defined type. For example: In the example above, whenever QML code attempts to update the Person.Name field via any means (direct assignment, object declarations, etc) the SetName method is invoked with the provided value instead. A setter method may also be used in conjunction with a getter method rather than a real type field. A method is only considered a getter in the presence of the respective setter, and according to common Go conventions it must not have the Get prefix. Inside QML logic, the getter and setter pair is seen as a single object property. Custom types implemented in Go may have displayable content by defining a Paint method such as: A simple example is available at: Resource files (qml code, images, etc) may be packed into the Go qml application binary to simplify its handling and distribution. This is done with the genqrc tool: The following blog post provides more details:
Package diskfs implements methods for creating and manipulating disks and filesystems methods for creating and manipulating disks and filesystems, whether block devices in /dev or direct disk images. This does **not** mount any disks or filesystems, neither directly locally nor via a VM. Instead, it manipulates the bytes directly. This is not intended as a replacement for operating system filesystem and disk drivers. Instead, it is intended to make it easy to work with partitions, partition tables and filesystems directly without requiring operating system mounts. Some examples: 1. Create a disk image of size 10MB with a FAT32 filesystem spanning the entire disk. Create a disk of size 20MB with an MBR partition table, a single partition beginning at block 2048 (1MB), of size 10MB filled with a FAT32 filesystem. import diskfs "github.com/x-clone/go-diskfs" diskSize := 10*1024*1024 // 10 MB diskImg := "/tmp/disk.img" disk := diskfs.Create(diskImg, size, diskfs.Raw) table := &mbr.Table{ LogicalSectorSize: 512, PhysicalSectorSize: 512, Partitions: []*mbr.Partition{ { Bootable: false, Type: Linux, Start: 2048, Size: 20480, }, }, } fs, err := disk.CreateFilesystem(1, diskfs.TypeFat32) Create a disk of size 20MB with a GPT partition table, a single partition beginning at block 2048 (1MB), of size 10MB, and fill with the contents from the 10MB file "/root/contents.dat" import diskfs "github.com/x-clone/go-diskfs" diskSize := 10*1024*1024 // 10 MB diskImg := "/tmp/disk.img" disk := diskfs.Create(diskImg, size, diskfs.Raw) table := &gpt.Table{ LogicalSectorSize: 512, PhysicalSectorSize: 512, Partitions: []*gpt.Partition{ { LogicalSectorSize: 512, PhysicalSectorSize: 512, ProtectiveMBR: true, }, }, } f, err := os.Open("/root/contents.dat") written, err := disk.WritePartitionContents(1, f) Create a disk of size 20MB with an MBR partition table, a single partition beginning at block 2048 (1MB), of size 10MB filled with a FAT32 filesystem, and create some directories and files in that filesystem. import diskfs "github.com/x-clone/go-diskfs" diskSize := 10*1024*1024 // 10 MB diskImg := "/tmp/disk.img" disk := diskfs.Create(diskImg, size, diskfs.Raw) table := &mbr.Table{ LogicalSectorSize: 512, PhysicalSectorSize: 512, Partitions: []*mbr.Partition{ { Bootable: false, Type: Linux, Start: 2048, Size: 20480, }, }, } fs, err := disk.CreateFilesystem(1, diskfs.TypeFat32) err := fs.Mkdir("/FOO/BAR") rw, err := fs.OpenFile("/FOO/BAR/AFILE.EXE", os.O_CREATE|os.O_RDRWR) b := make([]byte, 1024, 1024) rand.Read(b) err := rw.Write(b)
Package nlp provides implementations of selected machine learning algorithms for natural language processing of text corpora. The primary focus is the statistical semantics of plain-text documents supporting semantic analysis and retrieval of semantically similar documents. The package makes use of the Gonum (http://http//www.gonum.org/) library for linear algebra and scientific computing with some inspiration taken from Python's scikit-learn (http://scikit-learn.org/stable/) and Gensim(https://radimrehurek.com/gensim/) The primary intended use case is to support document input as text strings encoded as a matrix of numerical feature vectors called a `term document matrix`. Each column in the matrix corresponds to a document in the corpus and each row corresponds to a unique term occurring in the corpus. The individual elements within the matrix contain the frequency with which each term occurs within each document (referred to as `term frequency`). Whilst textual data from document corpora are the primary intended use case, the algorithms can be used with other types of data from other sources once encoded (vectorised) into a suitable matrix e.g. image data, sound data, users/products, etc. These matrices can be processed and manipulated through the application of additional transformations for weighting features, identifying relationships or optimising the data for analysis, information retrieval and/or predictions. Typically the algorithms in this package implement one of three primary interfaces: One of the implementations of Vectoriser is Pipeline which can be used to wire together pipelines composed of a Vectoriser and one or more Transformers arranged in serial so that the output from each stage forms the input of the next. This can be used to construct a classic LSI (Latent Semantic Indexing) pipeline (vectoriser -> TF.IDF weighting -> Truncated SVD): Whilst they take different inputs, both Vectorisers and Transformers have 3 primary methods:
Package nlp provides implementations of selected machine learning algorithms for natural language processing of text corpora. The primary focus is the statistical semantics of plain-text documents supporting semantic analysis and retrieval of semantically similar documents. The package makes use of the Gonum (http://http//www.gonum.org/) library for linear algebra and scientific computing with some inspiration taken from Python's scikit-learn (http://scikit-learn.org/stable/) and Gensim(https://radimrehurek.com/gensim/) The primary intended use case is to support document input as text strings encoded as a matrix of numerical feature vectors called a `term document matrix`. Each column in the matrix corresponds to a document in the corpus and each row corresponds to a unique term occurring in the corpus. The individual elements within the matrix contain the frequency with which each term occurs within each document (referred to as `term frequency`). Whilst textual data from document corpora are the primary intended use case, the algorithms can be used with other types of data from other sources once encoded (vectorised) into a suitable matrix e.g. image data, sound data, users/products, etc. These matrices can be processed and manipulated through the application of additional transformations for weighting features, identifying relationships or optimising the data for analysis, information retrieval and/or predictions. Typically the algorithms in this package implement one of three primary interfaces: One of the implementations of Vectoriser is Pipeline which can be used to wire together pipelines composed of a Vectoriser and one or more Transformers arranged in serial so that the output from each stage forms the input of the next. This can be used to construct a classic LSI (Latent Semantic Indexing) pipeline (vectoriser -> TF.IDF weighting -> Truncated SVD): Whilst they take different inputs, both Vectorisers and Transformers have 3 primary methods:
Package imaging provides basic image manipulation functions (resize, rotate, flip, crop, etc.). This package is based on the standard Go image package and works best along with it. Image manipulation functions provided by the package take any image type that implements `image.Image` interface as an input, and return a new image of `*image.NRGBA` type (32bit RGBA colors, not premultiplied by alpha). Imaging package uses parallel goroutines for faster image processing. To achieve maximum performance, make sure to allow Go to utilize all CPU cores: Here is the complete example that loades several images, makes thumbnails of them and joins them together.
Package diskfs implements methods for creating and manipulating disks and filesystems methods for creating and manipulating disks and filesystems, whether block devices in /dev or direct disk images. This does **not** mount any disks or filesystems, neither directly locally nor via a VM. Instead, it manipulates the bytes directly. This is not intended as a replacement for operating system filesystem and disk drivers. Instead, it is intended to make it easy to work with partitions, partition tables and filesystems directly without requiring operating system mounts. Some examples: 1. Create a disk image of size 10MB with a FAT32 filesystem spanning the entire disk. Create a disk of size 20MB with an MBR partition table, a single partition beginning at block 2048 (1MB), of size 10MB filled with a FAT32 filesystem. import diskfs "github.com/diskfs/go-diskfs" diskSize := 10*1024*1024 // 10 MB diskImg := "/tmp/disk.img" disk := diskfs.Create(diskImg, size, diskfs.Raw) table := &mbr.Table{ LogicalSectorSize: 512, PhysicalSectorSize: 512, Partitions: []*mbr.Partition{ { Bootable: false, Type: Linux, Start: 2048, Size: 20480, }, }, } fs, err := disk.CreateFilesystem(1, diskfs.TypeFat32) Create a disk of size 20MB with a GPT partition table, a single partition beginning at block 2048 (1MB), of size 10MB, and fill with the contents from the 10MB file "/root/contents.dat" import diskfs "github.com/diskfs/go-diskfs" diskSize := 10*1024*1024 // 10 MB diskImg := "/tmp/disk.img" disk := diskfs.Create(diskImg, size, diskfs.Raw) table := &gpt.Table{ LogicalSectorSize: 512, PhysicalSectorSize: 512, Partitions: []*gpt.Partition{ { LogicalSectorSize: 512, PhysicalSectorSize: 512, ProtectiveMBR: true, }, }, } f, err := os.Open("/root/contents.dat") written, err := disk.WritePartitionContents(1, f) Create a disk of size 20MB with an MBR partition table, a single partition beginning at block 2048 (1MB), of size 10MB filled with a FAT32 filesystem, and create some directories and files in that filesystem. import diskfs "github.com/diskfs/go-diskfs" diskSize := 10*1024*1024 // 10 MB diskImg := "/tmp/disk.img" disk := diskfs.Create(diskImg, size, diskfs.Raw) table := &mbr.Table{ LogicalSectorSize: 512, PhysicalSectorSize: 512, Partitions: []*mbr.Partition{ { Bootable: false, Type: Linux, Start: 2048, Size: 20480, }, }, } fs, err := disk.CreateFilesystem(1, diskfs.TypeFat32) err := fs.Mkdir("/FOO/BAR") rw, err := fs.OpenFile("/FOO/BAR/AFILE.EXE", os.O_CREATE|os.O_RDRWR) b := make([]byte, 1024, 1024) rand.Read(b) err := rw.Write(b)
Package diskfs implements methods for creating and manipulating disks and filesystems methods for creating and manipulating disks and filesystems, whether block devices in /dev or direct disk images. This does **not** mount any disks or filesystems, neither directly locally nor via a VM. Instead, it manipulates the bytes directly. This is not intended as a replacement for operating system filesystem and disk drivers. Instead, it is intended to make it easy to work with partitions, partition tables and filesystems directly without requiring operating system mounts. Some examples: 1. Create a disk image of size 10MB with a FAT32 filesystem spanning the entire disk. Create a disk of size 20MB with an MBR partition table, a single partition beginning at block 2048 (1MB), of size 10MB filled with a FAT32 filesystem. import diskfs "github.com/jonathongardner/go-diskfs" diskSize := 10*1024*1024 // 10 MB diskImg := "/tmp/disk.img" disk := diskfs.Create(diskImg, size, diskfs.Raw, diskfs.SectorSizeDefault) table := &mbr.Table{ LogicalSectorSize: 512, PhysicalSectorSize: 512, Partitions: []*mbr.Partition{ { Bootable: false, Type: Linux, Start: 2048, Size: 20480, }, }, } fs, err := disk.CreateFilesystem(1, diskfs.TypeFat32) Create a disk of size 20MB with a GPT partition table, a single partition beginning at block 2048 (1MB), of size 10MB, and fill with the contents from the 10MB file "/root/contents.dat" import diskfs "github.com/jonathongardner/go-diskfs" diskSize := 10*1024*1024 // 10 MB diskImg := "/tmp/disk.img" disk := diskfs.Create(diskImg, size, diskfs.Raw, diskfs.SectorSizeDefault) table := &gpt.Table{ LogicalSectorSize: 512, PhysicalSectorSize: 512, Partitions: []*gpt.Partition{ { LogicalSectorSize: 512, PhysicalSectorSize: 512, ProtectiveMBR: true, }, }, } f, err := os.Open("/root/contents.dat") written, err := disk.WritePartitionContents(1, f) Create a disk of size 20MB with an MBR partition table, a single partition beginning at block 2048 (1MB), of size 10MB filled with a FAT32 filesystem, and create some directories and files in that filesystem. import diskfs "github.com/jonathongardner/go-diskfs" diskSize := 10*1024*1024 // 10 MB diskImg := "/tmp/disk.img" disk := diskfs.Create(diskImg, size, diskfs.Raw, diskfs.SectorSizeDefault) table := &mbr.Table{ LogicalSectorSize: 512, PhysicalSectorSize: 512, Partitions: []*mbr.Partition{ { Bootable: false, Type: Linux, Start: 2048, Size: 20480, }, }, } fs, err := disk.CreateFilesystem(1, diskfs.TypeFat32) err := fs.Mkdir("/FOO/BAR") rw, err := fs.OpenFile("/FOO/BAR/AFILE.EXE", os.O_CREATE|os.O_RDRWR) b := make([]byte, 1024, 1024) rand.Read(b) err := rw.Write(b)
Package imaging provides basic image manipulation functions (resize, rotate, flip, crop, etc.). This package is based on the standard Go image package and works best along with it. Image manipulation functions provided by the package take any image type that implements `image.Image` interface as an input, and return a new image of `*image.NRGBA` type (32bit RGBA colors, not premultiplied by alpha). Imaging package uses parallel goroutines for faster image processing. To achieve maximum performance, make sure to allow Go to utilize all CPU cores:
Package mergi implements a image manipulation library mainly focusing on merge. See http://mergi.io for more information about mergi. Mergi library supports
Package diskfs implements methods for creating and manipulating disks and filesystems methods for creating and manipulating disks and filesystems, whether block devices in /dev or direct disk images. This does **not** mount any disks or filesystems, neither directly locally nor via a VM. Instead, it manipulates the bytes directly. This is not intended as a replacement for operating system filesystem and disk drivers. Instead, it is intended to make it easy to work with partitions, partition tables and filesystems directly without requiring operating system mounts. Some examples: 1. Create a disk image of size 10MB with a FAT32 filesystem spanning the entire disk. Create a disk of size 20MB with an MBR partition table, a single partition beginning at block 2048 (1MB), of size 10MB filled with a FAT32 filesystem. import diskfs "github.com/diskfs/go-diskfs" diskSize := 10*1024*1024 // 10 MB diskImg := "/tmp/disk.img" disk := diskfs.Create(diskImg, size, diskfs.Raw, diskfs.SectorSizeDefault) table := &mbr.Table{ LogicalSectorSize: 512, PhysicalSectorSize: 512, Partitions: []*mbr.Partition{ { Bootable: false, Type: Linux, Start: 2048, Size: 20480, }, }, } fs, err := disk.CreateFilesystem(1, diskfs.TypeFat32) Create a disk of size 20MB with a GPT partition table, a single partition beginning at block 2048 (1MB), of size 10MB, and fill with the contents from the 10MB file "/root/contents.dat" import diskfs "github.com/diskfs/go-diskfs" diskSize := 10*1024*1024 // 10 MB diskImg := "/tmp/disk.img" disk := diskfs.Create(diskImg, size, diskfs.Raw, diskfs.SectorSizeDefault) table := &gpt.Table{ LogicalSectorSize: 512, PhysicalSectorSize: 512, Partitions: []*gpt.Partition{ { LogicalSectorSize: 512, PhysicalSectorSize: 512, ProtectiveMBR: true, }, }, } f, err := os.Open("/root/contents.dat") written, err := disk.WritePartitionContents(1, f) Create a disk of size 20MB with an MBR partition table, a single partition beginning at block 2048 (1MB), of size 10MB filled with a FAT32 filesystem, and create some directories and files in that filesystem. import diskfs "github.com/diskfs/go-diskfs" diskSize := 10*1024*1024 // 10 MB diskImg := "/tmp/disk.img" disk := diskfs.Create(diskImg, size, diskfs.Raw, diskfs.SectorSizeDefault) table := &mbr.Table{ LogicalSectorSize: 512, PhysicalSectorSize: 512, Partitions: []*mbr.Partition{ { Bootable: false, Type: Linux, Start: 2048, Size: 20480, }, }, } fs, err := disk.CreateFilesystem(1, diskfs.TypeFat32) err := fs.Mkdir("/FOO/BAR") rw, err := fs.OpenFile("/FOO/BAR/AFILE.EXE", os.O_CREATE|os.O_RDRWR) b := make([]byte, 1024, 1024) rand.Read(b) err := rw.Write(b)
Package as1130 is a library for controlling the AS1130 LED driver, as used by The Matrix from Boldport. The device is configured using registers. Each register is represented as a struct with descriptive field names, comments, and default values. The struct can be passed to the corresponding Set method. You may also wish to refer to the datasheet: http://ams.com/eng/content/download/185846/834724/105034 To connect using the default device path and address: If you need to use another path or address: It's advisable to reset the device before using it: After which you must choose how many blink and PWM sets you want to use and perform the startup sequence. There's a helper method to make this easier: Or you can call SetConfig(), SetCurrentSource() and SetDisplayOption() yourself if you need more control. Frames are defined as grayscale images. They can be manipulated using standard Go image libraries: Each frame is associated with blink and PWM set, which defines flashing and intensity for individual LEDs. You should set the first (default) blink and PWM set at a minimum: An individual frame can be displayed in picture mode: Multiple frames can be displayed in movie mode: When you have finished setting all of the frames you can turn on the display: Have a look at the as1130ctl sub-package for more complete examples.
Package luar provides a convenient interface between Lua and Go. It uses Alessandro Arzilli's golua (https://github.com/aarzilli/golua). Most Go values can be passed to Lua: basic types, strings, complex numbers, user-defined types, pointers, composite types, functions, channels, etc. Conversely, most Lua values can be converted to Go values. Composite types are processed recursively. Methods can be called on user-defined types. These methods will be callable using _dot-notation_ rather than colon notation. Arrays, slices, maps and structs can be copied as tables, or alternatively passed over as Lua proxy objects which can be naturally indexed. In the case of structs and string maps, fields have priority over methods. Use 'luar.method(<value>, <method>)(<params>...)' to call shadowed methods. Unexported struct fields are ignored. The "lua" tag is used to match fields in struct conversion. You may pass a Lua table to an imported Go function; if the table is 'array-like' then it is converted to a Go slice; if it is 'map-like' then it is converted to a Go map. Pointer values encode as the value pointed to when unproxified. Usual operators (arithmetic, string concatenation, pairs/ipairs, etc.) work on proxies too. The type of the result depends on the type of the operands. The rules are as follows: - If the operands are of the same type, use this type. - If one type is a Lua number, use the other, user-defined type. - If the types are different and not Lua numbers, convert to a complex proxy, a Lua number, or a Lua string according to the result kind. Channel proxies can be manipulated with the following methods: - close(): Close the channel. - recv() value: Fetch and return a value from the channel. - send(x value): Send a value in the channel. Complex proxies can be manipulated with the following attributes: - real: The real part. - imag: The imaginary part. Slice proxies can be manipulated with the following methods/attributes: - append(x ...value) sliceProxy: Append the elements and return the new slice. The elements must be convertible to the slice element type. - cap: The capacity of the slice. - slice(i, j integer) sliceProxy: Return the sub-slice that ranges from 'i' to 'j' excluded, starting from 1. String proxies can be browsed rune by rune with the pairs/ipairs functions. These runes are encoded as strings in Lua. Indexing a string proxy (starting from 1) will return the corresponding byte as a Lua string. String proxies can be manipulated with the following method: - slice(i, j integer) sliceProxy: Return the sub-string that ranges from 'i' to 'j' excluded, starting from 1. Pointers to structs and structs within pointers are automatically dereferenced. Slices must be looped over with 'ipairs'.
Package diskfs implements methods for creating and manipulating disks and filesystems methods for creating and manipulating disks and filesystems, whether block devices in /dev or direct disk images. This does **not** mount any disks or filesystems, neither directly locally nor via a VM. Instead, it manipulates the bytes directly. This is not intended as a replacement for operating system filesystem and disk drivers. Instead, it is intended to make it easy to work with partitions, partition tables and filesystems directly without requiring operating system mounts. Some examples: 1. Create a disk image of size 10MB with a FAT32 filesystem spanning the entire disk. Create a disk of size 20MB with an MBR partition table, a single partition beginning at block 2048 (1MB), of size 10MB filled with a FAT32 filesystem. import diskfs "github.com/diskfs/go-diskfs" diskSize := 10*1024*1024 // 10 MB diskImg := "/tmp/disk.img" disk := diskfs.Create(diskImg, size, diskfs.Raw, diskfs.SectorSizeDefault) table := &mbr.Table{ LogicalSectorSize: 512, PhysicalSectorSize: 512, Partitions: []*mbr.Partition{ { Bootable: false, Type: Linux, Start: 2048, Size: 20480, }, }, } fs, err := disk.CreateFilesystem(1, diskfs.TypeFat32) Create a disk of size 20MB with a GPT partition table, a single partition beginning at block 2048 (1MB), of size 10MB, and fill with the contents from the 10MB file "/root/contents.dat" import diskfs "github.com/diskfs/go-diskfs" diskSize := 10*1024*1024 // 10 MB diskImg := "/tmp/disk.img" disk := diskfs.Create(diskImg, size, diskfs.Raw, diskfs.SectorSizeDefault) table := &gpt.Table{ LogicalSectorSize: 512, PhysicalSectorSize: 512, Partitions: []*gpt.Partition{ { LogicalSectorSize: 512, PhysicalSectorSize: 512, ProtectiveMBR: true, }, }, } f, err := os.Open("/root/contents.dat") written, err := disk.WritePartitionContents(1, f) Create a disk of size 20MB with an MBR partition table, a single partition beginning at block 2048 (1MB), of size 10MB filled with a FAT32 filesystem, and create some directories and files in that filesystem. import diskfs "github.com/diskfs/go-diskfs" diskSize := 10*1024*1024 // 10 MB diskImg := "/tmp/disk.img" disk := diskfs.Create(diskImg, size, diskfs.Raw, diskfs.SectorSizeDefault) table := &mbr.Table{ LogicalSectorSize: 512, PhysicalSectorSize: 512, Partitions: []*mbr.Partition{ { Bootable: false, Type: Linux, Start: 2048, Size: 20480, }, }, } fs, err := disk.CreateFilesystem(1, diskfs.TypeFat32) err := fs.Mkdir("/FOO/BAR") rw, err := fs.OpenFile("/FOO/BAR/AFILE.EXE", os.O_CREATE|os.O_RDRWR) b := make([]byte, 1024, 1024) rand.Read(b) err := rw.Write(b)
Package luar provides a convenient interface between Lua and Go. It uses Alessandro Arzilli's golua (https://github.com/aarzilli/golua). Most Go values can be passed to Lua: basic types, strings, complex numbers, user-defined types, pointers, composite types, functions, channels, etc. Conversely, most Lua values can be converted to Go values. Composite types are processed recursively. Methods can be called on user-defined types. These methods will be callable using _dot-notation_ rather than colon notation. Arrays, slices, maps and structs can be copied as tables, or alternatively passed over as Lua proxy objects which can be naturally indexed. In the case of structs and string maps, fields have priority over methods. Use 'luar.method(<value>, <method>)(<params>...)' to call shadowed methods. Unexported struct fields are ignored. The "lua" tag is used to match fields in struct conversion. You may pass a Lua table to an imported Go function; if the table is 'array-like' then it is converted to a Go slice; if it is 'map-like' then it is converted to a Go map. Pointer values encode as the value pointed to when unproxified. Usual operators (arithmetic, string concatenation, pairs/ipairs, etc.) work on proxies too. The type of the result depends on the type of the operands. The rules are as follows: - If the operands are of the same type, use this type. - If one type is a Lua number, use the other, user-defined type. - If the types are different and not Lua numbers, convert to a complex proxy, a Lua number, or a Lua string according to the result kind. Channel proxies can be manipulated with the following methods: - close(): Close the channel. - recv() value: Fetch and return a value from the channel. - send(x value): Send a value in the channel. Complex proxies can be manipulated with the following attributes: - real: The real part. - imag: The imaginary part. Slice proxies can be manipulated with the following methods/attributes: - append(x ...value) sliceProxy: Append the elements and return the new slice. The elements must be convertible to the slice element type. - cap: The capacity of the slice. - sub(i, j integer) sliceProxy: Return the sub-slice that ranges from 'i' to 'j' included. This matches Lua's behaviour, but not Go's. String proxies can be browsed rune by rune with the pairs/ipairs functions. These runes are encoded as strings in Lua. String proxies can be manipulated with the following method: - sub(i, j integer) sliceProxy: Return the sub-string that ranges from 'i' to 'j' included. This matches Lua's behaviour, but not Go's. Slices must be looped with 'ipairs'.
Package qml offers graphical QML application support for the Go language. This package is in an alpha stage, and still in heavy development. APIs may change, and things may break. At this time contributors and developers that are interested in tracking the development closely are encouraged to use it. If you'd prefer a more stable release, please hold on a bit and subscribe to the mailing list for news. It's in a pretty good state, so it shall not take too long. See http://github.com/go-qml/qml for details. The qml package enables Go programs to display and manipulate graphical content using Qt's QML framework. QML uses a declarative language to express structure and style, and supports JavaScript for in-place manipulation of the described content. When using the Go qml package, such QML content can also interact with Go values, making use of its exported fields and methods, and even explicitly creating new instances of registered Go types. A simple Go application that integrates with QML may perform the following steps for offering a graphical interface: Some of these topics are covered below, and may also be observed in practice in the following examples: The following logic demonstrates loading a QML file into a window: Any QML object may be manipulated by Go via the Object interface. That interface is implemented both by dynamic QML values obtained from a running engine, and by Go types in the qml package that represent QML values, such as Window, Context, and Engine. For example, the following logic creates a window and prints its width whenever it's made visible: Information about the methods, properties, and signals that are available for QML objects may be obtained in the Qt documentation. As a reference, the "visibleChanged" signal and the "width" property used in the example above are described at: When in doubt about what type is being manipulated, the Object.TypeName method provides the type name of the underlying value. The simplest way of making a Go value available to QML code is setting it as a variable of the engine's root context, as in: This logic would enable the following QML code to successfully run: While registering an individual Go value as described above is a quick way to get started, it is also fairly limited. For more flexibility, a Go type may be registered so that QML code can natively create new instances in an arbitrary position of the structure. This may be achieved via the RegisterType function, as the following example demonstrates: With this logic in place, QML code can create new instances of Person by itself: Independently from the mechanism used to publish a Go value to QML code, its methods and fields are available to QML logic as methods and properties of the respective QML object representing it. As required by QML, though, the Go method and field names are lowercased according to the following scheme when being accesed from QML: While QML code can directly read and write exported fields of Go values, as described above, a Go type can also intercept writes to specific fields by declaring a setter method according to common Go conventions. This is often useful for updating the internal state or the visible content of a Go-defined type. For example: In the example above, whenever QML code attempts to update the Person.Name field via any means (direct assignment, object declarations, etc) the SetName method is invoked with the provided value instead. A setter method may also be used in conjunction with a getter method rather than a real type field. A method is only considered a getter in the presence of the respective setter, and according to common Go conventions it must not have the Get prefix. Inside QML logic, the getter and setter pair is seen as a single object property. Custom types implemented in Go may have displayable content by defining a Paint method such as: A simple example is available at: Resource files (qml code, images, etc) may be packed into the Go qml application binary to simplify its handling and distribution. This is done with the genqrc tool: The following blog post provides more details:
Package luar provides a convenient interface between Lua and Go. It uses Alessandro Arzilli's golua (https://github.com/aarzilli/golua). Most Go values can be passed to Lua: basic types, strings, complex numbers, user-defined types, pointers, composite types, functions, channels, etc. Conversely, most Lua values can be converted to Go values. Composite types are processed recursively. Methods can be called on user-defined types. These methods will be callable using _dot-notation_ rather than colon notation. Arrays, slices, maps and structs can be copied as tables, or alternatively passed over as Lua proxy objects which can be naturally indexed. In the case of structs and string maps, fields have priority over methods. Use 'luar.method(<value>, <method>)(<params>...)' to call shadowed methods. Unexported struct fields are ignored. The "lua" tag is used to match fields in struct conversion. You may pass a Lua table to an imported Go function; if the table is 'array-like' then it is converted to a Go slice; if it is 'map-like' then it is converted to a Go map. Pointer values encode as the value pointed to when unproxified. Usual operators (arithmetic, string concatenation, pairs/ipairs, etc.) work on proxies too. The type of the result depends on the type of the operands. The rules are as follows: - If the operands are of the same type, use this type. - If one type is a Lua number, use the other, user-defined type. - If the types are different and not Lua numbers, convert to a complex proxy, a Lua number, or a Lua string according to the result kind. Channel proxies can be manipulated with the following methods: - close(): Close the channel. - recv() value: Fetch and return a value from the channel. - send(x value): Send a value in the channel. Complex proxies can be manipulated with the following attributes: - real: The real part. - imag: The imaginary part. Slice proxies can be manipulated with the following methods/attributes: - append(x ...value) sliceProxy: Append the elements and return the new slice. The elements must be convertible to the slice element type. - cap: The capacity of the slice. - slice(i, j integer) sliceProxy: Return the sub-slice that ranges from 'i' to 'j' excluded, starting from 1. String proxies can be browsed rune by rune with the pairs/ipairs functions. These runes are encoded as strings in Lua. Indexing a string proxy (starting from 1) will return the corresponding byte as a Lua string. String proxies can be manipulated with the following method: - slice(i, j integer) sliceProxy: Return the sub-string that ranges from 'i' to 'j' excluded, starting from 1. Pointers to structs and structs within pointers are automatically dereferenced. Slices must be looped over with 'ipairs'.
Package pack is the reference implementation of a Cloud Native Buildpacks platform. Its purpose is to simplify the transformation of application source code, into a runnable OCI images. In order to use most pack functionality, you will need to have Docker installed. For easy installation instructions see: https://docs.docker.com/desktop/. This package provides functionality to create and manipulate all artifacts outlined in the Cloud Native Buildpacks specification. An introduction to these artifacts and their usage can be found at https://buildpacks.io/docs/. The formal specification of the pack platform provides can be found at: https://github.com/buildpacks/spec. This example shows the basic usage of the package: Create a client, call a configuration object, call the client's Build function.
Package goquery implements features similar to jQuery, including the chainable syntax, to manipulate and query an HTML document. It brings a syntax and a set of features similar to jQuery to the Go language. It is based on Go's net/html package and the CSS Selector library cascadia. Since the net/html parser returns nodes, and not a full-featured DOM tree, jQuery's stateful manipulation functions (like height(), css(), detach()) have been left off. Also, because the net/html parser requires UTF-8 encoding, so does goquery: it is the caller's responsibility to ensure that the source document provides UTF-8 encoded HTML. See the repository's wiki for various options on how to do this. Syntax-wise, it is as close as possible to jQuery, with the same method names when possible, and that warm and fuzzy chainable interface. jQuery being the ultra-popular library that it is, writing a similar HTML-manipulating library was better to follow its API than to start anew (in the same spirit as Go's fmt package), even though some of its methods are less than intuitive (looking at you, index()...). It is hosted on GitHub, along with additional documentation in the README.md file: https://github.com/puerkitobio/goquery Please note that because of the net/html dependency, goquery requires Go1.1+. The various methods are split into files based on the category of behavior. The three dots (...) indicate that various "overloads" are available. * array.go : array-like positional manipulation of the selection. * expand.go : methods that expand or augment the selection's set. * filter.go : filtering methods, that reduce the selection's set. * iteration.go : methods to loop over the selection's nodes. * manipulation.go : methods for modifying the document * property.go : methods that inspect and get the node's properties values. * query.go : methods that query, or reflect, a node's identity. * traversal.go : methods to traverse the HTML document tree. * type.go : definition of the types exposed by goquery. * utilities.go : definition of helper functions (and not methods on a *Selection) that are not part of jQuery, but are useful to goquery. This example scrapes the reviews shown on the home page of metalsucks.net.
Package nlp provides implementations of selected machine learning algorithms for natural language processing of text corpora. The primary focus is the statistical semantics of plain-text documents supporting semantic analysis and retrieval of semantically similar documents. The package makes use of the Gonum (http://http//www.gonum.org/) library for linear algebra and scientific computing with some inspiration taken from Python's scikit-learn (http://scikit-learn.org/stable/) and Gensim(https://radimrehurek.com/gensim/) The primary intended use case is to support document input as text strings encoded as a matrix of numerical feature vectors called a `term document matrix`. Each column in the matrix corresponds to a document in the corpus and each row corresponds to a unique term occurring in the corpus. The individual elements within the matrix contain the frequency with which each term occurs within each document (referred to as `term frequency`). Whilst textual data from document corpora are the primary intended use case, the algorithms can be used with other types of data from other sources once encoded (vectorised) into a suitable matrix e.g. image data, sound data, users/products, etc. These matrices can be processed and manipulated through the application of additional transformations for weighting features, identifying relationships or optimising the data for analysis, information retrieval and/or predictions. Typically the algorithms in this package implement one of three primary interfaces: One of the implementations of Vectoriser is Pipeline which can be used to wire together pipelines composed of a Vectoriser and one or more Transformers arranged in serial so that the output from each stage forms the input of the next. This can be used to construct a classic LSI (Latent Semantic Indexing) pipeline (vectoriser -> TF.IDF weighting -> Truncated SVD): Whilst they take different inputs, both Vectorisers and Transformers have 3 primary methods:
Package imaging provides basic image manipulation functions (resize, rotate, flip, crop, etc.). This package is based on the standard Go image package and works best along with it. Image manipulation functions provided by the package take any image type that implements `image.Image` interface as an input, and return a new image of `*image.NRGBA` type (32bit RGBA colors, not premultiplied by alpha).
Package luar provides a convenient interface between Lua and Go. It uses Alessandro Arzilli's golua (https://github.com/nwidger/golua). Most Go values can be passed to Lua: basic types, strings, complex numbers, user-defined types, pointers, composite types, functions, channels, etc. Conversely, most Lua values can be converted to Go values. Composite types are processed recursively. Methods can be called on user-defined types. These methods will be callable using _dot-notation_ rather than colon notation. Arrays, slices, maps and structs can be copied as tables, or alternatively passed over as Lua proxy objects which can be naturally indexed. In the case of structs and string maps, fields have priority over methods. Use 'luar.method(<value>, <method>)(<params>...)' to call shadowed methods. Unexported struct fields are ignored. The "lua" tag is used to match fields in struct conversion. You may pass a Lua table to an imported Go function; if the table is 'array-like' then it is converted to a Go slice; if it is 'map-like' then it is converted to a Go map. Pointer values encode as the value pointed to when unproxified. Usual operators (arithmetic, string concatenation, pairs/ipairs, etc.) work on proxies too. The type of the result depends on the type of the operands. The rules are as follows: - If the operands are of the same type, use this type. - If one type is a Lua number, use the other, user-defined type. - If the types are different and not Lua numbers, convert to a complex proxy, a Lua number, or a Lua string according to the result kind. Channel proxies can be manipulated with the following methods: - close(): Close the channel. - recv() value: Fetch and return a value from the channel. - send(x value): Send a value in the channel. Complex proxies can be manipulated with the following attributes: - real: The real part. - imag: The imaginary part. Slice proxies can be manipulated with the following methods/attributes: - append(x ...value) sliceProxy: Append the elements and return the new slice. The elements must be convertible to the slice element type. - cap: The capacity of the slice. - slice(i, j integer) sliceProxy: Return the sub-slice that ranges from 'i' to 'j' excluded, starting from 1. String proxies can be browsed rune by rune with the pairs/ipairs functions. These runes are encoded as strings in Lua. Indexing a string proxy (starting from 1) will return the corresponding byte as a Lua string. String proxies can be manipulated with the following method: - slice(i, j integer) sliceProxy: Return the sub-string that ranges from 'i' to 'j' excluded, starting from 1. Pointers to structs and structs within pointers are automatically dereferenced. Slices must be looped over with 'ipairs'.
Package luar provides a convenient interface between Lua and Go. It uses Alessandro Arzilli's golua (https://github.com/aarzilli/golua). Most Go values can be passed to Lua: basic types, strings, complex numbers, user-defined types, pointers, composite types, functions, channels, etc. Conversely, most Lua values can be converted to Go values. Composite types are processed recursively. Methods can be called on user-defined types. These methods will be callable using _dot-notation_ rather than colon notation. Arrays, slices, maps and structs can be copied as tables, or alternatively passed over as Lua proxy objects which can be naturally indexed. In the case of structs and string maps, fields have priority over methods. Use 'luar.method(<value>, <method>)(<params>...)' to call shadowed methods. Unexported struct fields are ignored. The "lua" tag is used to match fields in struct conversion. You may pass a Lua table to an imported Go function; if the table is 'array-like' then it is converted to a Go slice; if it is 'map-like' then it is converted to a Go map. Pointer values encode as the value pointed to when unproxified. Usual operators (arithmetic, string concatenation, pairs/ipairs, etc.) work on proxies too. The type of the result depends on the type of the operands. The rules are as follows: - If the operands are of the same type, use this type. - If one type is a Lua number, use the other, user-defined type. - If the types are different and not Lua numbers, convert to a complex proxy, a Lua number, or a Lua string according to the result kind. Channel proxies can be manipulated with the following methods: - close(): Close the channel. - recv() value: Fetch and return a value from the channel. - send(x value): Send a value in the channel. Complex proxies can be manipulated with the following attributes: - real: The real part. - imag: The imaginary part. Slice proxies can be manipulated with the following methods/attributes: - append(x ...value) sliceProxy: Append the elements and return the new slice. The elements must be convertible to the slice element type. - cap: The capacity of the slice. - slice(i, j integer) sliceProxy: Return the sub-slice that ranges from 'i' to 'j' excluded, starting from 1. String proxies can be browsed rune by rune with the pairs/ipairs functions. These runes are encoded as strings in Lua. Indexing a string proxy (starting from 1) will return the corresponding byte as a Lua string. String proxies can be manipulated with the following method: - slice(i, j integer) sliceProxy: Return the sub-string that ranges from 'i' to 'j' excluded, starting from 1. Pointers to structs and structs within pointers are automatically dereferenced. Slices must be looped over with 'ipairs'.
Package diskfs implements methods for creating and manipulating disks and filesystems methods for creating and manipulating disks and filesystems, whether block devices in /dev or direct disk images. This does **not** mount any disks or filesystems, neither directly locally nor via a VM. Instead, it manipulates the bytes directly. This is not intended as a replacement for operating system filesystem and disk drivers. Instead, it is intended to make it easy to work with partitions, partition tables and filesystems directly without requiring operating system mounts. Some examples: 1. Create a disk image of size 10MB with a FAT32 filesystem spanning the entire disk. Create a disk of size 20MB with an MBR partition table, a single partition beginning at block 2048 (1MB), of size 10MB filled with a FAT32 filesystem. import diskfs "github.com/cusspvz/go-diskfs" diskSize := 10*1024*1024 // 10 MB diskImg := "/tmp/disk.img" disk := diskfs.Create(diskImg, size, diskfs.Raw) table := &mbr.Table{ LogicalSectorSize: 512, PhysicalSectorSize: 512, Partitions: []*mbr.Partition{ { Bootable: false, Type: Linux, Start: 2048, Size: 20480, }, }, } fs, err := disk.CreateFilesystem(1, diskfs.TypeFat32) Create a disk of size 20MB with a GPT partition table, a single partition beginning at block 2048 (1MB), of size 10MB, and fill with the contents from the 10MB file "/root/contents.dat" import diskfs "github.com/cusspvz/go-diskfs" diskSize := 10*1024*1024 // 10 MB diskImg := "/tmp/disk.img" disk := diskfs.Create(diskImg, size, diskfs.Raw) table := &gpt.Table{ LogicalSectorSize: 512, PhysicalSectorSize: 512, Partitions: []*gpt.Partition{ { LogicalSectorSize: 512, PhysicalSectorSize: 512, ProtectiveMBR: true, }, }, } f, err := os.Open("/root/contents.dat") written, err := disk.WritePartitionContents(1, f) Create a disk of size 20MB with an MBR partition table, a single partition beginning at block 2048 (1MB), of size 10MB filled with a FAT32 filesystem, and create some directories and files in that filesystem. import diskfs "github.com/cusspvz/go-diskfs" diskSize := 10*1024*1024 // 10 MB diskImg := "/tmp/disk.img" disk := diskfs.Create(diskImg, size, diskfs.Raw) table := &mbr.Table{ LogicalSectorSize: 512, PhysicalSectorSize: 512, Partitions: []*mbr.Partition{ { Bootable: false, Type: Linux, Start: 2048, Size: 20480, }, }, } fs, err := disk.CreateFilesystem(1, diskfs.TypeFat32) err := fs.Mkdir("/FOO/BAR") rw, err := fs.OpenFile("/FOO/BAR/AFILE.EXE", os.O_CREATE|os.O_RDRWR) b := make([]byte, 1024, 1024) rand.Read(b) err := rw.Write(b)
Package imaging provides basic image manipulation functions (resize, rotate, flip, crop, etc.). This package is based on the standard Go image package and works best along with it. Image manipulation functions provided by the package take any image type that implements `image.Image` interface as an input, and return a new image of `*image.NRGBA` type (32bit RGBA colors, not premultiplied by alpha).
Package gosvg defines functions and data for generating SVG documents as defined by the Scalable Vector Graphics 1.1 Specification (http://www.w3.org/TR/SVG11/). Supported elements and functions: Shapes elements: circle, ellipse, line, path, polygon, polyline, rect Structural elements: g, svg Transforms: All transforms Style: All styling At the highest level of the gosvg package is the SVG type. Users can create a new SVG instance by calling NewSVG at the package level. SVG objects can then be used to generate basic shape elements or other SVG fragments and Group objects. Upon creating a new element, SVG and Group objects retain a reference to that new element for later rendering. Users should define how their images will look by manipulating the objects generated by SVGs and Groups. When the image is ready to be rendered, users should call Render on the top-level SVG object in the hierarchy to write a full XML document to the provided io.Writer. For example, the following program generates a circle inside a square: Objects are written as XML in the order that they are created by SVG and Group objects. Thus, if two objects overlap in the image, the one created later will be rendered on top of the one created earlier by a conforming SVG viewer.
Package imaging provides basic image manipulation functions (resize, rotate, flip, crop, etc.). This package is based on the standard Go image package and works best along with it. Image manipulation functions provided by the package take any image type that implements `image.Image` interface as an input, and return a new image of `*image.NRGBA` type (32bit RGBA colors, not premultiplied by alpha).
Package imaging provides basic image manipulation functions (resize, rotate, flip, crop, etc.). This package is based on the standard Go image package and works best along with it. Image manipulation functions provided by the package take any image type that implements `image.Image` interface as an input, and return a new image of `*image.NRGBA` type (32bit RGBA colors, not premultiplied by alpha).
Package imaging provides basic image manipulation functions (resize, rotate, flip, crop, etc.). This package is based on the standard Go image package and works best along with it. Image manipulation functions provided by the package take any image type that implements `image.Image` interface as an input, and return a new image of `*image.NRGBA` type (32bit RGBA colors, not premultiplied by alpha).
Package cap provides all the Linux Capabilities userspace library API bindings in native Go. Capabilities are a feature of the Linux kernel that allow fine grain permissions to perform privileged operations. Privileged operations are required to do irregular system level operations from code. You can read more about how Capabilities are intended to work here: This package supports native Go bindings for all the features described in that paper as well as supporting subsequent changes to the kernel for other styles of inheritable Capability. Some simple things you can do with this package are: The "cap" package operates with POSIX semantics for security state. That is all OS threads are kept in sync at all times. The package "kernel.org/pub/linux/libs/security/libcap/psx" is used to implement POSIX semantics system calls that manipulate thread state uniformly over the whole Go (and any CGo linked) process runtime. Note, if the Go runtime syscall interface contains the Linux variant syscall.AllThreadsSyscall() API (it debuted in go1.16 see https://github.com/golang/go/issues/1435 for its history) then the "libcap/psx" package will use that to invoke Capability setting system calls in pure Go binaries. With such an enhanced Go runtime, to force this behavior, use the CGO_ENABLED=0 environment variable. POSIX semantics are more secure than trying to manage privilege at a thread level when those threads share a common memory image as they do under Linux: it is trivial to exploit a vulnerability in one thread of a process to cause execution on any another thread. So, any imbalance in security state, in such cases will readily create an opportunity for a privilege escalation vulnerability. POSIX semantics also work well with Go, which deliberately tries to insulate the user from worrying about the number of OS threads that are actually running in their program. Indeed, Go can efficiently launch and manage tens of thousands of concurrent goroutines without bogging the program or wider system down. It does this by aggressively migrating idle threads to make progress on unblocked goroutines. So, inconsistent security state across OS threads can also lead to program misbehavior. The only exception to this process-wide common security state is the cap.Launcher related functionality. This briefly locks an OS thread to a goroutine in order to launch another executable - the robust implementation of this kind of support is quite subtle, so please read its documentation carefully, if you find that you need it. See https://sites.google.com/site/fullycapable/ for recent updates, some more complete walk-through examples of ways of using 'cap.Set's etc and information on how to file bugs. Copyright (c) 2019-21 Andrew G. Morgan <morgan@kernel.org> The cap and psx packages are licensed with a (you choose) BSD 3-clause or GPL2. See LICENSE file for details.
Package cops contains packages for rendering terminal user interfaces. Cops supports 24 bit color and pairs well with the "color", "image", and "image/draw" packages. The "display" package models a display as foreground, background, and text layers. The display package provides Draw for composing display layers and Render for producing ANSI escape sequences to differentially update a terminal. The display package also includes an ANSI cursor, colors, palettes, and rendering models for 0, 3, 4, 8, and 24 bit color. The "textile" package implements a text layer, like Go's own "image" package. The "text" package measures and cuts text onto a display. The "terminal" package provides an idiomatic Go interface for terminal capabilities ("raw mode", "no echo", getting and setting size). The "rectangle" package provides conveniences for manipulating image rectangles for display composition. The "bitmap" package provides a compact representation of bitmap images, suitable for use as masks or sources for braille bitmap displays. The "braille" package draws bitmap images onto displays as a matrix of braille text.
Package nlp provides implementations of selected machine learning algorithms for natural language processing of text corpora. The primary focus is the statistical semantics of plain-text documents supporting semantic analysis and retrieval of semantically similar documents. The package makes use of the Gonum (http://http//www.gonum.org/) library for linear algebra and scientific computing with some inspiration taken from Python's scikit-learn (http://scikit-learn.org/stable/) and Gensim(https://radimrehurek.com/gensim/) The primary intended use case is to support document input as text strings encoded as a matrix of numerical feature vectors called a `term document matrix`. Each column in the matrix corresponds to a document in the corpus and each row corresponds to a unique term occurring in the corpus. The individual elements within the matrix contain the frequency with which each term occurs within each document (referred to as `term frequency`). Whilst textual data from document corpora are the primary intended use case, the algorithms can be used with other types of data from other sources once encoded (vectorised) into a suitable matrix e.g. image data, sound data, users/products, etc. These matrices can be processed and manipulated through the application of additional transformations for weighting features, identifying relationships or optimising the data for analysis, information retrieval and/or predictions. Typically the algorithms in this package implement one of three primary interfaces: One of the implementations of Vectoriser is Pipeline which can be used to wire together pipelines composed of a Vectoriser and one or more Transformers arranged in serial so that the output from each stage forms the input of the next. This can be used to construct a classic LSI (Latent Semantic Indexing) pipeline (vectoriser -> TF.IDF weighting -> Truncated SVD): Whilst they take different inputs, both Vectorisers and Transformers have 3 primary methods:
Package gorph manipulates graphic images in order to procedurally modify or create derived images. The datastructures and algorithms provided allow client codes to pre-render or procedurally generate new images from base images. This library is designed to use the standard libraries as much as possible in order to leverage the "image" and "image/color" libraries heavily.
Package mergi implements a image manipulation library mainly focusing on merge. See http://mergi.io for more information about mergi. Mergi library supports
Package imaging provides basic image manipulation functions (resize, rotate, flip, crop, etc.). This package is based on the standard Go image package and works best along with it. Image manipulation functions provided by the package take any image type that implements `image.Image` interface as an input, and return a new image of `*image.NRGBA` type (32bit RGBA colors, not premultiplied by alpha). Imaging package uses parallel goroutines for faster image processing. To achieve maximum performance, make sure to allow Go to utilize all CPU cores: Here is the complete example that loades several images, makes thumbnails of them and joins them together.
Package nlp provides implementations of selected machine learning algorithms for natural language processing of text corpora. The primary focus is the statistical semantics of plain-text documents supporting semantic analysis and retrieval of semantically similar documents. The package makes use of the Gonum (http://http//www.gonum.org/) library for linear algebra and scientific computing with some inspiration taken from Python's scikit-learn (http://scikit-learn.org/stable/) and Gensim(https://radimrehurek.com/gensim/) The primary intended use case is to support document input as text strings encoded as a matrix of numerical feature vectors called a `term document matrix`. Each column in the matrix corresponds to a document in the corpus and each row corresponds to a unique term occurring in the corpus. The individual elements within the matrix contain the frequency with which each term occurs within each document (referred to as `term frequency`). Whilst textual data from document corpora are the primary intended use case, the algorithms can be used with other types of data from other sources once encoded (vectorised) into a suitable matrix e.g. image data, sound data, users/products, etc. These matrices can be processed and manipulated through the application of additional transformations for weighting features, identifying relationships or optimising the data for analysis, information retrieval and/or predictions. Typically the algorithms in this package implement one of three primary interfaces: One of the implementations of Vectoriser is Pipeline which can be used to wire together pipelines composed of a Vectoriser and one or more Transformers arranged in serial so that the output from each stage forms the input of the next. This can be used to construct a classic LSI (Latent Semantic Indexing) pipeline (vectoriser -> TF.IDF weighting -> Truncated SVD): Whilst they take different inputs, both Vectorisers and Transformers have 3 primary methods:
Package diskfs implements methods for creating and manipulating disks and filesystems methods for creating and manipulating disks and filesystems, whether block devices in /dev or direct disk images. This does **not** mount any disks or filesystems, neither directly locally nor via a VM. Instead, it manipulates the bytes directly. This is not intended as a replacement for operating system filesystem and disk drivers. Instead, it is intended to make it easy to work with partitions, partition tables and filesystems directly without requiring operating system mounts. Some examples: 1. Create a disk image of size 10MB with a FAT32 filesystem spanning the entire disk.
Package diskfs implements methods for creating and manipulating disks and filesystems methods for creating and manipulating disks and filesystems, whether block devices in /dev or direct disk images. This does **not** mount any disks or filesystems, neither directly locally nor via a VM. Instead, it manipulates the bytes directly. This is not intended as a replacement for operating system filesystem and disk drivers. Instead, it is intended to make it easy to work with partitions, partition tables and filesystems directly without requiring operating system mounts. Some examples: 1. Create a disk image of size 10MB with a FAT32 filesystem spanning the entire disk.
Package diskfs implements methods for creating and manipulating disks and filesystems methods for creating and manipulating disks and filesystems, whether block devices in /dev or direct disk images. This does **not** mount any disks or filesystems, neither directly locally nor via a VM. Instead, it manipulates the bytes directly. This is not intended as a replacement for operating system filesystem and disk drivers. Instead, it is intended to make it easy to work with partitions, partition tables and filesystems directly without requiring operating system mounts. Some examples: 1. Create a disk image of size 10MB with a FAT32 filesystem spanning the entire disk.
Package luar provides a convenient interface between Lua and Go. It uses Alessandro Arzilli's golua (https://github.com/vxcontrol/golua). Most Go values can be passed to Lua: basic types, strings, complex numbers, user-defined types, pointers, composite types, functions, channels, etc. Conversely, most Lua values can be converted to Go values. Composite types are processed recursively. Methods can be called on user-defined types. These methods will be callable using _dot-notation_ rather than colon notation. Arrays, slices, maps and structs can be copied as tables, or alternatively passed over as Lua proxy objects which can be naturally indexed. In the case of structs and string maps, fields have priority over methods. Use 'luar.method(<value>, <method>)(<params>...)' to call shadowed methods. Unexported struct fields are ignored. The "lua" tag is used to match fields in struct conversion. You may pass a Lua table to an imported Go function; if the table is 'array-like' then it is converted to a Go slice; if it is 'map-like' then it is converted to a Go map. Pointer values encode as the value pointed to when unproxified. Usual operators (arithmetic, string concatenation, pairs/ipairs, etc.) work on proxies too. The type of the result depends on the type of the operands. The rules are as follows: - If the operands are of the same type, use this type. - If one type is a Lua number, use the other, user-defined type. - If the types are different and not Lua numbers, convert to a complex proxy, a Lua number, or a Lua string according to the result kind. Channel proxies can be manipulated with the following methods: - close(): Close the channel. - recv() value: Fetch and return a value from the channel. - send(x value): Send a value in the channel. Complex proxies can be manipulated with the following attributes: - real: The real part. - imag: The imaginary part. Slice proxies can be manipulated with the following methods/attributes: - append(x ...value) sliceProxy: Append the elements and return the new slice. The elements must be convertible to the slice element type. - cap: The capacity of the slice. - slice(i, j integer) sliceProxy: Return the sub-slice that ranges from 'i' to 'j' excluded, starting from 1. String proxies can be browsed rune by rune with the pairs/ipairs functions. These runes are encoded as strings in Lua. Indexing a string proxy (starting from 1) will return the corresponding byte as a Lua string. String proxies can be manipulated with the following method: - slice(i, j integer) sliceProxy: Return the sub-string that ranges from 'i' to 'j' excluded, starting from 1. Pointers to structs and structs within pointers are automatically dereferenced. Slices must be looped over with 'ipairs'.
Package plates provides utilities for manipulating colors and images.
Package qml offers graphical QML application support for the Go language. This package is in an alpha stage, and still in heavy development. APIs may change, and things may break. At this time contributors and developers that are interested in tracking the development closely are encouraged to use it. If you'd prefer a more stable release, please hold on a bit and subscribe to the mailing list for news. It's in a pretty good state, so it shall not take too long. See http://github.com/go-qml/qml for details. The qml package enables Go programs to display and manipulate graphical content using Qt's QML framework. QML uses a declarative language to express structure and style, and supports JavaScript for in-place manipulation of the described content. When using the Go qml package, such QML content can also interact with Go values, making use of its exported fields and methods, and even explicitly creating new instances of registered Go types. A simple Go application that integrates with QML may perform the following steps for offering a graphical interface: Some of these topics are covered below, and may also be observed in practice in the following examples: The following logic demonstrates loading a QML file into a window: Any QML object may be manipulated by Go via the Object interface. That interface is implemented both by dynamic QML values obtained from a running engine, and by Go types in the qml package that represent QML values, such as Window, Context, and Engine. For example, the following logic creates a window and prints its width whenever it's made visible: Information about the methods, properties, and signals that are available for QML objects may be obtained in the Qt documentation. As a reference, the "visibleChanged" signal and the "width" property used in the example above are described at: When in doubt about what type is being manipulated, the Object.TypeName method provides the type name of the underlying value. The simplest way of making a Go value available to QML code is setting it as a variable of the engine's root context, as in: This logic would enable the following QML code to successfully run: While registering an individual Go value as described above is a quick way to get started, it is also fairly limited. For more flexibility, a Go type may be registered so that QML code can natively create new instances in an arbitrary position of the structure. This may be achieved via the RegisterType function, as the following example demonstrates: With this logic in place, QML code can create new instances of Person by itself: Independently from the mechanism used to publish a Go value to QML code, its methods and fields are available to QML logic as methods and properties of the respective QML object representing it. As required by QML, though, the Go method and field names are lowercased according to the following scheme when being accesed from QML: While QML code can directly read and write exported fields of Go values, as described above, a Go type can also intercept writes to specific fields by declaring a setter method according to common Go conventions. This is often useful for updating the internal state or the visible content of a Go-defined type. For example: In the example above, whenever QML code attempts to update the Person.Name field via any means (direct assignment, object declarations, etc) the SetName method is invoked with the provided value instead. A setter method may also be used in conjunction with a getter method rather than a real type field. A method is only considered a getter in the presence of the respective setter, and according to common Go conventions it must not have the Get prefix. Inside QML logic, the getter and setter pair is seen as a single object property. Custom types implemented in Go may have displayable content by defining a Paint method such as: A simple example is available at: Resource files (qml code, images, etc) may be packed into the Go qml application binary to simplify its handling and distribution. This is done with the genqrc tool: The following blog post provides more details:
Package imaging provides basic image manipulation functions (resize, rotate, flip, crop, etc.). This package is based on the standard Go image package and works best along with it. Image manipulation functions provided by the package take any image type that implements `image.Image` interface as an input, and return a new image of `*image.NRGBA` type (32bit RGBA colors, not premultiplied by alpha).
Package diskfs implements methods for creating and manipulating disks and filesystems methods for creating and manipulating disks and filesystems, whether block devices in /dev or direct disk images. This does **not** mount any disks or filesystems, neither directly locally nor via a VM. Instead, it manipulates the bytes directly. This is not intended as a replacement for operating system filesystem and disk drivers. Instead, it is intended to make it easy to work with partitions, partition tables and filesystems directly without requiring operating system mounts. Some examples: 1. Create a disk image of size 10MB with a FAT32 filesystem spanning the entire disk. Create a disk of size 20MB with an MBR partition table, a single partition beginning at block 2048 (1MB), of size 10MB filled with a FAT32 filesystem. import diskfs "github.com/dave/diskfs" diskSize := 10*1024*1024 // 10 MB diskImg := "/tmp/disk.img" disk := diskfs.Create(diskImg, size, diskfs.Raw) table := &mbr.Table{ LogicalSectorSize: 512, PhysicalSectorSize: 512, Partitions: []*mbr.Partition{ { Bootable: false, Type: Linux, Start: 2048, Size: 20480, }, }, } fs, err := disk.CreateFilesystem(1, diskfs.TypeFat32) Create a disk of size 20MB with a GPT partition table, a single partition beginning at block 2048 (1MB), of size 10MB, and fill with the contents from the 10MB file "/root/contents.dat" import diskfs "github.com/dave/diskfs" diskSize := 10*1024*1024 // 10 MB diskImg := "/tmp/disk.img" disk := diskfs.Create(diskImg, size, diskfs.Raw) table := &gpt.Table{ LogicalSectorSize: 512, PhysicalSectorSize: 512, Partitions: []*gpt.Partition{ { LogicalSectorSize: 512, PhysicalSectorSize: 512, ProtectiveMBR: true, }, }, } f, err := os.Open("/root/contents.dat") written, err := disk.WritePartitionContents(1, f) Create a disk of size 20MB with an MBR partition table, a single partition beginning at block 2048 (1MB), of size 10MB filled with a FAT32 filesystem, and create some directories and files in that filesystem. import diskfs "github.com/dave/diskfs" diskSize := 10*1024*1024 // 10 MB diskImg := "/tmp/disk.img" disk := diskfs.Create(diskImg, size, diskfs.Raw) table := &mbr.Table{ LogicalSectorSize: 512, PhysicalSectorSize: 512, Partitions: []*mbr.Partition{ { Bootable: false, Type: Linux, Start: 2048, Size: 20480, }, }, } fs, err := disk.CreateFilesystem(1, diskfs.TypeFat32) err := fs.Mkdir("/FOO/BAR") rw, err := fs.OpenFile("/FOO/BAR/AFILE.EXE", os.O_CREATE|os.O_RDRWR) b := make([]byte, 1024, 1024) rand.Read(b) err := rw.Write(b)
Package diskfs implements methods for creating and manipulating disks and filesystems methods for creating and manipulating disks and filesystems, whether block devices in /dev or direct disk images. This does **not** mount any disks or filesystems, neither directly locally nor via a VM. Instead, it manipulates the bytes directly. This is not intended as a replacement for operating system filesystem and disk drivers. Instead, it is intended to make it easy to work with partitions, partition tables and filesystems directly without requiring operating system mounts. Some examples: 1. Create a disk image of size 10MB with a FAT32 filesystem spanning the entire disk.
Package imaging provides basic image manipulation functions (resize, rotate, flip, crop, etc.). This package is based on the standard Go image package and works best along with it. Image manipulation functions provided by the package take any image type that implements `image.Image` interface as an input, and return a new image of `*image.NRGBA` type (32bit RGBA colors, not premultiplied by alpha). Imaging package uses parallel goroutines for faster image processing. To achieve maximum performance, make sure to allow Go to utilize all CPU cores: Here is the complete example that loades several images, makes thumbnails of them and joins them together.
Package diskfs implements methods for creating and manipulating disks and filesystems methods for creating and manipulating disks and filesystems, whether block devices in /dev or direct disk images. This does **not** mount any disks or filesystems, neither directly locally nor via a VM. Instead, it manipulates the bytes directly. This is not intended as a replacement for operating system filesystem and disk drivers. Instead, it is intended to make it easy to work with partitions, partition tables and filesystems directly without requiring operating system mounts. Some examples: 1. Create a disk image of size 10MB with a FAT32 filesystem spanning the entire disk.