Categorygithub.com/wbroberts/go-react
modulepackage
0.1.1
Repository: https://github.com/wbroberts/go-react.git
Documentation: pkg.go.dev

# README

Go React

Wanted to learn Go so started with a simple CLI to can create the boilerplate for files.

Install

go install github.com/wbroberts/go-react

Use

go-react

Component

Creates a component and component test file.

go-react component <ComponentName>

Options:

  • --props or -p adds an empty props type for component
  • --skip-tests skips adding the test file
  • --dir or -d sets the path for the directory the component should be added to. Will create the directory if it does not exist yet

Example

go-react component Example
  • Component ./components/Example.component.tsx
import React from 'react';

export const Example = () => {
  return <div>Example renders</div>;
}
  • Component test ./components/Example.component.test.tsx
import { screen, render } from '@testing-library/react';

import { Example } from './Example.component';

describe('Example', () => {
  it('renders', () => {
    render(<Example />);
  
    expect(screen.getByText(/Example renders/)).toBeDefined();
  });
});

Optional Config File for Defaults

Can add a config file to set default flags when running commands.

touch go-react.yaml

# All values are optional
component:
  dir: src/components
  props: true
  skip-tests: false

# Packages

Copyright © 2022 NAME HERE <EMAIL ADDRESS> */.