8000 feat(new tool): Json to Go by sharevb · Pull Request #1031 · CorentinTh/it-tools · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat(new tool): Json to Go #1031

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/tools/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { tool as asciiTextDrawer } from './ascii-text-drawer';

import { tool as textToUnicode } from './text-to-unicode';
import { tool as safelinkDecoder } from './safelink-decoder';
import { tool as jsonToGo } from './json-to-go';
import { tool as pdfSignatureChecker } from './pdf-signature-checker';
import { tool as numeronymGenerator } from './numeronym-generator';
import { tool as macAddressGenerator } from './mac-address-generator';
Expand Down Expand Up @@ -107,6 +108,7 @@ export const toolsByCategory: ToolCategory[] = [
listConverter,
tomlToJson,
tomlToYaml,
jsonToGo,
],
},
{
Expand Down
12 changes: 12 additions & 0 deletions src/tools/json-to-go/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { Braces } from '@vicons/tabler';
import { defineTool } from '../tool';

export const tool = defineTool({
name: 'JSON to Go',
path: '/json-to-go',
description: 'Convert JSON to Go struct',
keywords: ['json', 'parse', 'go', 'convert', 'transform'],
component: () => import('./json-to-go.vue'),
icon: Braces,
createdAt: new Date('2024-04-02'),
});
20 changes: 20 additions & 0 deletions src/tools/json-to-go/json-to-go.service.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { describe, expect, it } from 'vitest';
import { jsonToGo } from './json-to-go.service';
import testCases from './json-to-go.test.data.json';

describe('json-to-go', () => {
describe('jsonToGo', () => {
for (const includeExampleData of [true, false]) {
it(`must return correct results (includeExampleData = ${includeExampleData})`, () => {
for (const testCase of testCases) {
const got = jsonToGo(testCase.input, '', false, includeExampleData);
const expected = includeExampleData
? testCase.expectedWithExample
: testCase.expected;

expect(got.go).to.equal(expected);
}
});
}
});
});
Loading
0