Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

go_gem

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

go_gem

  • 0.5.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

GoGem

Helpers for compiling Go extensions for ruby

Gem Version

Installation

Add below.

spec.add_dependency "go_gem"

See below for details.

/_tools/patch_for_go_gem/

Usage

create_go_makefile

create_go_makefile is an extension of create_makefile.

Add a task and hacks to build Go against the Makefile generated by create_makefile.

e.g.

# ext/GEM_NAME/extconf.rb

require "mkmf"
require "go_gem/mkmf" # Append this

# Use create_go_makefile instead of create_makefile
# create_makefile("example/example")
create_go_makefile("example/example")

GoGem::RakeTask

Provides rake tasks for go test with CRuby

Example (Without config)
# Rakefile
require "go_gem/rake_task"

GoGem::RakeTask.new("gem_name")

Following tasks are generated

  • rake go:test
  • rake go:testrace
  • rake go:fmt
  • rake go:build_envs
Example (With config)
# Rakefile
require "go_gem/rake_task"

GoGem::RakeTask.new("gem_name") do |t|
  t.task_namespace = "go5"
  t.go_bin_path = "/path/to/go"
  t.go_test_args = "-mod=readonly"
  t.target_dir = "/dir/to/go-mod/"
end

Following tasks are generated

  • rake go5:test
  • rake go5:testrace
  • rake go5:fmt
  • rake go5:build_envs
Example (Add additional tasks)
# Rakefile
require "go_gem/rake_task"

go_task = GoGem::RakeTask.new("gem_name")

namespace :go do
  desc "Run golangci-lint"
  task :lint do
    go_task.within_target_dir do
      sh "which golangci-lint" do |ok, _|
        raise "golangci-lint isn't installed. See. https://golangci-lint.run/welcome/install/" unless ok
      end
      sh GoGem::RakeTask.build_env_vars, "golangci-lint run"
    end
  end
end
Example (Use golangci/golangci-lint-action)
jobs:
  go-lint:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-go@v5
      - uses: ruby/setup-ruby@v1

      - name: export CGO_CFLAGS for golangci-lint
        run: bundle exec rake go:build_envs[CGO_CFLAGS] >> $GITHUB_ENV

      - name: Run golangci-lint
        uses: golangci/golangci-lint-action@v6
Available configurations
  • task_namespace : task namespace (default: :go)
  • go_bin_path : path to go binary (default: "go")
  • go_test_args : argument passed to go test (default: "-mod=readonly -count=1")
  • target_dir : directory when executing go commands. (default: "ext/#{gem_name}")

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and the created tag, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/ruby-go-gem/go-gem-wrapper.

License

The gem is available as open source under the terms of the MIT License.

FAQs

Package last updated on 26 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc